本文整理汇总了Java中com.trollworks.toolkit.utility.FileType类的典型用法代码示例。如果您正苦于以下问题:Java FileType类的具体用法?Java FileType怎么用?Java FileType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FileType类属于com.trollworks.toolkit.utility包,在下文中一共展示了FileType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configureApplication
import com.trollworks.toolkit.utility.FileType; //导入依赖的package包/类
@Override
public void configureApplication(CmdLine cmdLine) {
if (Platform.isWindows()) {
Map<String, String> map = new HashMap<>();
for (FileType fileType : FileType.getAll()) {
if (fileType.shouldRegisterAppForOpening()) {
map.put(fileType.getExtension(), fileType.getDescription());
}
}
Path home = App.getHomePath();
WindowsRegistry.register("GCS", map, home.resolve("gcs"), home.resolve("support")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
UpdateChecker.check("gcs", WEB_SITE + "/versions.txt", WEB_SITE); //$NON-NLS-1$ //$NON-NLS-2$
ListCollectionThread.get();
StdMenuBar.configure(new FileMenuProvider(), new EditMenuProvider(), new ItemMenuProvider(), new HelpMenuProvider());
OutputPreferences.initialize(); // Must come before SheetPreferences.initialize()
SheetPreferences.initialize();
PreferencesWindow.addCategory(SheetPreferences::new);
PreferencesWindow.addCategory(OutputPreferences::new);
PreferencesWindow.addCategory(FontPreferences::new);
PreferencesWindow.addCategory(MenuKeyPreferences::new);
PreferencesWindow.addCategory(ReferenceLookupPreferences::new);
}
示例2: addRecent
import com.trollworks.toolkit.utility.FileType; //导入依赖的package包/类
/** @param file The {@link File} to add to the recents list. */
public static void addRecent(File file) {
String extension = PathUtils.getExtension(file.getName());
if (Platform.isMacintosh() || Platform.isWindows()) {
extension = extension.toLowerCase();
}
for (String allowed : FileType.getOpenableExtensions()) {
if (allowed.equals(extension)) {
if (file.canRead()) {
file = PathUtils.getFile(PathUtils.getFullPath(file));
RECENTS.remove(file);
RECENTS.add(0, file);
if (RECENTS.size() > MAX_RECENTS) {
RECENTS.remove(MAX_RECENTS);
}
}
break;
}
}
}
示例3: registerFileTypes
import com.trollworks.toolkit.utility.FileType; //导入依赖的package包/类
/**
* Registers the file types the app can open.
*
* @param fileProxyCreator The {@link FileProxyCreator} to use.
*/
public static void registerFileTypes(FileProxyCreator fileProxyCreator) {
FileType.register(GURPSCharacter.EXTENSION, GCSImages.getCharacterSheetDocumentIcons(), SHEET_DESCRIPTION, REFERENCE_URL, fileProxyCreator, true, true);
FileType.register(AdvantageList.EXTENSION, GCSImages.getAdvantagesDocumentIcons(), ADVANTAGES_LIBRARY_DESCRIPTION, REFERENCE_URL, fileProxyCreator, true, true);
FileType.register(EquipmentList.EXTENSION, GCSImages.getEquipmentDocumentIcons(), EQUIPMENT_LIBRARY_DESCRIPTION, REFERENCE_URL, fileProxyCreator, true, true);
FileType.register(SkillList.EXTENSION, GCSImages.getSkillsDocumentIcons(), SKILLS_LIBRARY_DESCRIPTION, REFERENCE_URL, fileProxyCreator, true, true);
FileType.register(SpellList.EXTENSION, GCSImages.getSpellsDocumentIcons(), SPELLS_LIBRARY_DESCRIPTION, REFERENCE_URL, fileProxyCreator, true, true);
FileType.register(Template.EXTENSION, GCSImages.getTemplateDocumentIcons(), TEMPLATE_DESCRIPTION, REFERENCE_URL, fileProxyCreator, true, true);
// For legacy
FileType.register(LibraryFile.EXTENSION, GCSImages.getAdvantagesDocumentIcons(), LIBRARY_DESCRIPTION, REFERENCE_URL, fileProxyCreator, true, true);
FileType.registerPdf(GCSImages.getPDFDocumentIcons(), fileProxyCreator, true, false);
FileType.registerHtml(null, null, false, false);
FileType.registerPng(null, null, false, false);
}
示例4: getAllowedFileTypes
import com.trollworks.toolkit.utility.FileType; //导入依赖的package包/类
@Override
public FileType[] getAllowedFileTypes() {
File textTemplate = TextTemplate.resolveTextTemplate(null);
String extension = PathUtils.getExtension(textTemplate.getName());
FileType templateType = FileType.getByExtension(extension);
if (templateType == null) {
FileType.register(extension, null, String.format(TEXT_TEMPLATE_DESCRIPTION, extension), "", null, false, false); //$NON-NLS-1$
}
templateType = FileType.getByExtension(extension);
return new FileType[] { FileType.getByExtension(GURPSCharacter.EXTENSION), FileType.getByExtension(FileType.PDF_EXTENSION), FileType.getByExtension(FileType.PNG_EXTENSION), templateType };
}
示例5: saveTo
import com.trollworks.toolkit.utility.FileType; //导入依赖的package包/类
@Override
public File[] saveTo(File file) {
ArrayList<File> result = new ArrayList<>();
String extension = PathUtils.getExtension(file.getName());
File textTemplate = TextTemplate.resolveTextTemplate(null);
String templateExtension = PathUtils.getExtension(textTemplate.getName());
if (FileType.PNG_EXTENSION.equals(extension)) {
if (!mSheet.saveAsPNG(file, result)) {
WindowUtils.showError(this, EXPORT_PNG_ERROR);
}
} else if (FileType.PDF_EXTENSION.equals(extension)) {
if (mSheet.saveAsPDF(file)) {
result.add(file);
} else {
WindowUtils.showError(this, EXPORT_PDF_ERROR);
}
} else if (templateExtension.equals(extension)) {
if (new TextTemplate(mSheet).export(file, null)) {
result.add(file);
} else {
WindowUtils.showError(this, EXPORT_TEXT_TEMPLATE_ERROR);
}
} else {
return super.saveTo(file);
}
return result.toArray(new File[result.size()]);
}
示例6: save
import com.trollworks.toolkit.utility.FileType; //导入依赖的package包/类
void save(XMLWriter out) {
out.startSimpleTagEOL(TAG_ROOT);
out.simpleTagNotEmpty(TAG_PLAYER_NAME, mPlayerName);
out.simpleTagNotEmpty(TAG_CAMPAIGN, mCampaign);
out.simpleTagNotEmpty(TAG_NAME, mName);
out.simpleTagNotEmpty(TAG_TITLE, mTitle);
out.simpleTag(TAG_AGE, mAge);
out.simpleTagNotEmpty(TAG_BIRTHDAY, mBirthday);
out.simpleTagNotEmpty(TAG_EYES, mEyeColor);
out.simpleTagNotEmpty(TAG_HAIR, mHair);
out.simpleTagNotEmpty(TAG_SKIN, mSkinColor);
out.simpleTagNotEmpty(TAG_HANDEDNESS, mHandedness);
if (mHeight.getNormalizedValue() != 0) {
out.simpleTag(TAG_HEIGHT, mHeight.toString(false));
}
if (mWeight.getNormalizedValue() != 0) {
out.simpleTag(TAG_WEIGHT, mWeight.toString(false));
}
out.simpleTag(BonusAttributeType.SM.getXMLTag(), mSizeModifier);
out.simpleTagNotEmpty(TAG_GENDER, mGender);
out.simpleTagNotEmpty(TAG_RACE, mRace);
out.simpleTag(TAG_BODY_TYPE, mHitLocationTable.getKey());
out.simpleTagNotEmpty(TAG_TECH_LEVEL, mTechLevel);
out.simpleTagNotEmpty(TAG_RELIGION, mReligion);
if (mCustomPortrait && mPortrait != null) {
try {
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
ImageIO.write(mPortrait.getRetina(), FileType.PNG_EXTENSION, baos);
out.writeComment(PORTRAIT_COMMENT);
out.startSimpleTagEOL(TAG_PORTRAIT);
out.println(Text.standardizeLineEndings(Base64.getMimeEncoder().encodeToString(baos.toByteArray())));
out.endTagEOL(TAG_PORTRAIT, true);
}
} catch (Exception ex) {
throw new RuntimeException(PORTRAIT_WRITE_ERROR);
}
}
out.endTagEOL(TAG_ROOT, true);
}
示例7: choosePortrait
import com.trollworks.toolkit.utility.FileType; //导入依赖的package包/类
public static File choosePortrait() {
List<FileNameExtensionFilter> filters = new ArrayList<>();
filters.add(new FileNameExtensionFilter(ALL_READABLE_IMAGE_FILES, FileType.PNG_EXTENSION, FileType.JPEG_EXTENSION, "jpeg", FileType.GIF_EXTENSION)); //$NON-NLS-1$
filters.add(FileType.getPngFilter());
filters.add(FileType.getJpegFilter());
filters.add(FileType.getGifFilter());
return StdFileDialog.showOpenDialog(null, SELECT_PORTRAIT, filters);
}
示例8: visitFile
import com.trollworks.toolkit.utility.FileType; //导入依赖的package包/类
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
if (!shouldSkip(file)) {
String ext = PathUtils.getExtension(file.getFileName());
for (String one : FileType.getOpenableExtensions()) {
if (one.equalsIgnoreCase(ext)) {
mCurrent.add(file);
break;
}
}
}
return FileVisitResult.CONTINUE;
}
示例9: open
import com.trollworks.toolkit.utility.FileType; //导入依赖的package包/类
/** @param file The file to open. */
public static void open(File file) {
if (file != null) {
try {
String name = file.getName();
FileProxy proxy = AppWindow.findFileProxy(file);
if (proxy == null) {
for (FileType type : FileType.getOpenable()) {
if (name.matches(StdFileDialog.createExtensionMatcher(type.getExtension()))) {
proxy = type.getFileProxyCreator().create(file);
break;
}
}
} else {
proxy.toFrontAndFocus();
}
if (proxy != null) {
RecentFilesMenu.addRecent(file);
} else {
throw new IOException("Unknown file extension"); //$NON-NLS-1$
}
} catch (Exception exception) {
Log.error(exception);
StdFileDialog.showCannotOpenMsg(getFocusOwner(), file.getName(), exception);
}
}
}
示例10: getFileType
import com.trollworks.toolkit.utility.FileType; //导入依赖的package包/类
@Override
// Not used
public FileType getFileType() {
return null;
}
示例11: getFileType
import com.trollworks.toolkit.utility.FileType; //导入依赖的package包/类
@Override
public FileType getFileType() {
return FileType.getByExtension(EXTENSION);
}
示例12: getPDFDocumentIcons
import com.trollworks.toolkit.utility.FileType; //导入依赖的package包/类
/** @return The PDF icons. */
public static final StdImageSet getPDFDocumentIcons() {
return getDocumentIcons(FileType.PDF_EXTENSION);
}
示例13: main
import com.trollworks.toolkit.utility.FileType; //导入依赖的package包/类
/** Utility for creating GCS's icon sets. */
public static void main(String[] args) {
String name = "GenerateIcons";
Attributes attributes = new Attributes();
attributes.putValue(BundleInfo.BUNDLE_NAME, name);
attributes.putValue(BundleInfo.BUNDLE_VERSION, "1.0");
attributes.putValue(BundleInfo.BUNDLE_COPYRIGHT_OWNER, "Richard A. Wilkes");
attributes.putValue(BundleInfo.BUNDLE_COPYRIGHT_YEARS, "2014");
attributes.putValue(BundleInfo.BUNDLE_LICENSE, "Mozilla Public License 2.0");
BundleInfo.setDefault(new BundleInfo(attributes, name));
CmdLineOption icnsOption = new CmdLineOption("Generate ICNS files", null, "icns");
CmdLineOption icoOption = new CmdLineOption("Generate ICO files", null, "ico");
CmdLineOption appOption = new CmdLineOption("Generate just the 128x128 app icon", null, "app");
CmdLineOption dirOption = new CmdLineOption("The directory to place the generated files into", "DIR", "dir");
CmdLine cmdline = new CmdLine();
cmdline.addOptions(icnsOption, icoOption, appOption, dirOption);
cmdline.processArguments(args);
boolean icns = cmdline.isOptionUsed(icnsOption);
boolean ico = cmdline.isOptionUsed(icoOption);
boolean app = cmdline.isOptionUsed(appOption);
if (!icns && !ico && !app) {
System.err.printf("At least one of %s, %s, or %s must be specified.\n", icnsOption, icoOption, appOption);
System.exit(1);
}
try {
File dir = new File(cmdline.isOptionUsed(dirOption) ? cmdline.getOptionArgument(dirOption) : ".");
System.out.println("Generating icons into " + dir);
dir.mkdirs();
if (app) {
File file = new File(dir, "gcs.png");
if (StdImage.writePNG(file, getAppIcons().getImage(128), 72)) {
System.out.println("Created: " + file);
} else {
System.err.println("Unable to create: " + file);
}
}
if (icns || ico) {
createIconFiles(getAppIcons(), dir, "app", icns, ico);
createIconFiles(getAdvantagesDocumentIcons(), dir, AdvantageList.EXTENSION, icns, ico);
createIconFiles(getEquipmentDocumentIcons(), dir, EquipmentList.EXTENSION, icns, ico);
createIconFiles(getCharacterSheetDocumentIcons(), dir, GURPSCharacter.EXTENSION, icns, ico);
createIconFiles(getTemplateDocumentIcons(), dir, Template.EXTENSION, icns, ico);
createIconFiles(getSkillsDocumentIcons(), dir, SkillList.EXTENSION, icns, ico);
createIconFiles(getSpellsDocumentIcons(), dir, SpellList.EXTENSION, icns, ico);
createIconFiles(getPDFDocumentIcons(), dir, FileType.PDF_EXTENSION, icns, ico);
}
} catch (Exception exception) {
exception.printStackTrace(System.err);
}
}
示例14: saveAsPNG
import com.trollworks.toolkit.utility.FileType; //导入依赖的package包/类
/**
* @param file The file to save to.
* @param createdFiles The files that were created.
* @return <code>true</code> on success.
*/
public boolean saveAsPNG(File file, ArrayList<File> createdFiles) {
HashSet<Row> changed = expandAllContainers();
try {
int dpi = OutputPreferences.getPNGResolution();
PrintManager settings = mCharacter.getPageSettings();
PageFormat format = settings != null ? settings.createPageFormat() : createDefaultPageFormat();
Paper paper = format.getPaper();
int width = (int) (paper.getWidth() / 72.0 * dpi);
int height = (int) (paper.getHeight() / 72.0 * dpi);
StdImage buffer = StdImage.create(width, height, Transparency.OPAQUE);
int pageNum = 0;
String name = PathUtils.getLeafName(file.getName(), false);
file = file.getParentFile();
adjustToPageSetupChanges(true);
setPrinting(true);
while (true) {
File pngFile;
Graphics2D gc = buffer.getGraphics();
if (print(gc, format, pageNum) == NO_SUCH_PAGE) {
gc.dispose();
break;
}
gc.setClip(0, 0, width, height);
gc.setBackground(Color.WHITE);
gc.clearRect(0, 0, width, height);
gc.scale(dpi / 72.0, dpi / 72.0);
print(gc, format, pageNum++);
gc.dispose();
pngFile = new File(file, PathUtils.enforceExtension(name + (pageNum > 1 ? " " + pageNum : ""), FileType.PNG_EXTENSION)); //$NON-NLS-1$ //$NON-NLS-2$
if (!StdImage.writePNG(pngFile, buffer, dpi)) {
throw new IOException();
}
createdFiles.add(pngFile);
}
return true;
} catch (Exception exception) {
return false;
} finally {
setPrinting(false);
closeContainers(changed);
}
}
示例15: getTitleIcon
import com.trollworks.toolkit.utility.FileType; //导入依赖的package包/类
@Override
public Icon getTitleIcon() {
return FileType.getIconsForFileExtension(FileType.PDF_EXTENSION).getImage(16);
}