private boolean setupDefaultProperties() { fontProps = new Properties(); // create program properties with default try { // If you application needs to look at other font directories // they can be added via the readSystemFonts method. fontManager.readSystemFonts(null); fontProps = fontManager.getFontProperties(); } catch (Exception ex) { if (getBoolean("application.showLocalStorageDialogs", true)) { Resources.showMessageDialog( null, JOptionPane.ERROR_MESSAGE, messageBundle, "fontManager.properties.title", "manager.properties.session.readError", ex); } // log the error if (logger.isLoggable(Level.WARNING)) { logger.log(Level.WARNING, "Error loading default properties", ex); } return false; } return true; }
public FontPropertiesManager( PropertiesManager appProps, Properties sysProps, ResourceBundle messageBundle) { this.sysProps = sysProps; this.props = appProps; this.fontProps = new Properties(); this.messageBundle = messageBundle; // create a new Font Manager. this.fontManager = FontManager.getInstance(); setupHomeDir(null); recordMofifTime(); setupLock(); loadProperties(); }
public void setAppearanceStream() { // copy over annotation properties from the free text annotation. if (fontFile == null || freeTextAnnotation.isFontPropertyChanged()) { fontFile = FontManager.getInstance() .getType1AWTFont(freeTextAnnotation.getFontName(), freeTextAnnotation.getFontSize()); } freeTextPane.setFont(fontFile); freeTextPane.setForeground(freeTextAnnotation.getFontColor()); if (freeTextAnnotation.isFillType()) { freeTextPane.setOpaque(true); freeTextPane.setBackground(freeTextAnnotation.getFillColor()); } else { freeTextPane.setOpaque(false); } if (freeTextAnnotation.isStrokeType()) { if (freeTextAnnotation.getBorderStyle().isStyleSolid()) { freeTextPane.setBorder( BorderFactory.createLineBorder( freeTextAnnotation.getColor(), (int) freeTextAnnotation.getBorderStyle().getStrokeWidth())); } else if (freeTextAnnotation.getBorderStyle().isStyleDashed()) { freeTextPane.setBorder( new DashedBorder(freeTextAnnotation.getBorderStyle(), freeTextAnnotation.getColor())); } } else { freeTextPane.setBorder(BorderFactory.createEmptyBorder()); } String content = null; try { content = freeTextPane.getDocument().getText(0, freeTextPane.getDocument().getLength()); } catch (BadLocationException e) { logger.warning("Error getting rich text."); } Rectangle tBbox = convertToPageSpace(getBounds()); // generate the shapes freeTextAnnotation.setBBox(tBbox); freeTextAnnotation.setContents(content); freeTextAnnotation.setRichText(freeTextPane.getText()); freeTextPane.revalidate(); }
public synchronized void loadProperties() { if (dataDir != null) { propertyFile = new File(dataDir, USER_FILENAME); // load font properties from last invocation if (propertyFile.exists()) { try { InputStream in = new FileInputStream(propertyFile); try { fontProps.load(in); fontManager.setFontProperties(fontProps); } finally { in.close(); } } catch (IOException ex) { // check to make sure the storage relate dialogs can be shown if (getBoolean("application.showLocalStorageDialogs", true)) { Resources.showMessageDialog( null, JOptionPane.ERROR_MESSAGE, messageBundle, "fontManager.properties.title", "manager.properties.session.readError", ex); } // log the error if (logger.isLoggable(Level.WARNING)) { logger.log(Level.WARNING, "Error loading font properties cache", ex); } } catch (IllegalArgumentException e) { // propblem parsing fontProps, reread teh file setupDefaultProperties(); saveProperties(); } } // If no font data, then read font data and save the new file. else { setupDefaultProperties(); saveProperties(); } } }