public Object getData(final RepositoryEntry entry, final Repository repository) throws IOException { final String productName = entry.getProductFile().getName(); final PropertyMap propertyMap = repository.getPropertyMap(); final String boundaryPathString = propertyMap.getPropertyString(productName + KEY_BOUNDARY_PATH, null); final Double latValue = propertyMap.getPropertyDouble(productName + KEY_PRODUCT_CENTER_LAT, null); final Double lonValue = propertyMap.getPropertyDouble(productName + KEY_PRODUCT_CENTER_LON, null); final PropertyMap dataMap = new PropertyMap(); dataMap.setPropertyString(KEY_BOUNDARY_PATH, boundaryPathString); dataMap.setPropertyDouble(KEY_PRODUCT_CENTER_LAT, latValue); dataMap.setPropertyDouble(KEY_PRODUCT_CENTER_LON, lonValue); return dataMap; }
/** * Gets a value of type <code>Font</code>. The method actually looks for three keys in order to construct the font * instance: <ld> <li><code><key>.name</code> for the font's name</li> <li><code><key>.style</code> for * the font's style (an integer value)</li> <li><code><key>.name</code> for the font's size in points (an * integer value)</li> </ld> * * @param key the key * @param defaultValue the default value that is returned if the key was not found in this property set. * * @return the value for the given key, or <code>defaultValue</code> if the key is not contained in this property * set. */ public Font getPropertyFont(String key, Font defaultValue) { Guardian.assertNotNullOrEmpty("key", key); String fontName = getPropertyString(key + ".name", null); if (fontName != null) { int fontStyle = getPropertyInt(key + ".style", java.awt.Font.PLAIN); int fontSize = getPropertyInt(key + ".size", 12); return new Font(fontName, fontStyle, fontSize); } return defaultValue; }
private void initPreferences() { preferences = new PropertyMap(); preferences.setPropertyBool(PROPERTY_KEY_APP_DEBUG_ENABLED, false); preferences.setPropertyString(PROPERTY_KEY_APP_UI_FONT_NAME, "SansSerif"); preferences.setPropertyInt(PROPERTY_KEY_APP_UI_FONT_SIZE, 12); preferences.setPropertyBool(PROPERTY_KEY_APP_LOG_ENABLED, false); preferences.setPropertyString(PROPERTY_KEY_APP_LOG_PREFIX, getAppName()); preferences.setPropertyString(PROPERTY_KEY_APP_LOG_LEVEL, SystemUtils.LLS_INFO); preferences.setPropertyBool(PROPERTY_KEY_APP_LOG_ECHO, false); preferencesFile = new File(appUserDir, "preferences.properties"); loadPreferences(); suppressibleOptionPane = new SuppressibleOptionPane(getPreferences()); }
private void clearRepositoryList() { for (int i = 0; i < _properties.getProperties().size(); i++) { final String propertyName = createRepositoryPropertyName(i); if (_properties.getPropertyString(propertyName) != "") { _properties.setPropertyString(propertyName, null); } } }
@Override public void actionPerformed(ActionEvent e) { final boolean usingUrl = refresh(); if (usingUrl) { final String urls = propertyMap.getPropertyString(PROPERTY_KEY_SERVER_URLS); final String currentUrl = urlField.getSelectedItem().toString(); if (!urls.contains(currentUrl)) { propertyMap.setPropertyString(PROPERTY_KEY_SERVER_URLS, urls + "\n" + currentUrl); updateUrlField(); } } } });
assertTrue(_e.getAbsolutePath() + " deos not exist", _e.exists()); final String propertyKey = "recent.files."; final PropertyMap properties = new PropertyMap(); properties.setPropertyInt(propertyKey + ".length", 3); properties.setPropertyString(propertyKey + ".0", _a.getAbsolutePath()); properties.setPropertyString(propertyKey + ".1", _b.getAbsolutePath()); properties.setPropertyString(propertyKey + ".2", _c.getAbsolutePath()); properties.setPropertyString(propertyKey + ".3", _d.getAbsolutePath()); properties.setPropertyString(propertyKey + ".4", _e.getAbsolutePath()); assertEquals(2, properties.getPropertyInt(propertyKey + ".length")); assertEquals(_e.getAbsolutePath(), properties.getPropertyString(propertyKey + ".0")); assertEquals(_d.getAbsolutePath(), properties.getPropertyString(propertyKey + ".1")); assertNull(properties.getPropertyString(propertyKey + ".2", null)); assertNull(properties.getPropertyString(propertyKey + ".3", null)); assertNull(properties.getPropertyString(propertyKey + ".4", null));
public Object getData(final RepositoryEntry entry, final Repository repository) throws IOException { final String productName = entry.getProductFile().getName(); final PropertyMap propertyMap = repository.getPropertyMap(); final PropertyMap properties = new PropertyMap(); for (final String propertyKey : PROPERTY_KEYS) { final String typeString = propertyMap.getPropertyString(productName + propertyKey, null); properties.setPropertyString(propertyKey, typeString); } return properties; }
/** * Retrieves thelast selected repository. * * @return the last selected repsoitory, maybe <code>null</code>. */ public String getLastSelectedRepositoryDir() { return _properties.getPropertyString(CURRENT_REPSOITORY_KEY, null); }
private void importMaskFromBmd(File file) { final PropertyMap propertyMap = new PropertyMap(); try { propertyMap.load(file); // Overwrite existing values final String name = propertyMap.getPropertyString("bitmaskName", "bitmask"); final String description = propertyMap.getPropertyString("bitmaskDesc", null); final String expression = propertyMap.getPropertyString("bitmaskExpr", ""); final Color color = propertyMap.getPropertyColor("bitmaskColor", Color.yellow); final float transparency = (float) propertyMap.getPropertyDouble("bitmaskTransparency", 0.5); final Product product = getMaskForm().getProduct(); product.addMask(name, expression, description, color, transparency); } catch (Exception e) { showErrorDialog(String.format("Failed to import mask(s): %s", e.getMessage())); } }
private void setIODir(final PropertyMap propertyMap, final File dir) { if (dir != null) { propertyMap.setPropertyString(shapeIoDirPreferencesKey, dir.getPath()); } }
final PropertyMap propertyMap = new PropertyMap(); propertyMap.load(file); // Overwrite existing values final int numPoints = propertyMap.getPropertyInt(_PROPERTY_KEY_NUM_POINTS); if (numPoints < 2) { throw new IOException("The selected file contains less than\n" + for (int i = 0; i < points.length; i++) { final ColorPaletteDef.Point point = new ColorPaletteDef.Point(); final Color color = propertyMap.getPropertyColor(_PROPERTY_KEY_COLOR + i); double sample = propertyMap.getPropertyDouble(_PROPERTY_KEY_SAMPLE + i); if (i > 0 && sample < lastSample) { sample = lastSample + 1.0; paletteDef.setAutoDistribute(propertyMap.getPropertyBool(_PROPERTY_KEY_AUTODISTRIBUTE, false)); return paletteDef;
/** * Stores this color palette definition in the given file * * @param colorPaletteDef thje color palette definition * @param file the file * * @throws IOException if an I/O error occurs */ public static void storeColorPaletteDef(ColorPaletteDef colorPaletteDef, File file) throws IOException { final ColorPaletteDef.Point[] points = colorPaletteDef.getPoints(); final PropertyMap propertyMap = new PropertyMap(); final int numPoints = points.length; propertyMap.setPropertyInt(_PROPERTY_KEY_NUM_POINTS, numPoints); propertyMap.setPropertyBool(_PROPERTY_KEY_AUTODISTRIBUTE, colorPaletteDef.isAutoDistribute()); for (int i = 0; i < numPoints; i++) { propertyMap.setPropertyColor(_PROPERTY_KEY_COLOR + i, points[i].getColor()); propertyMap.setPropertyDouble(_PROPERTY_KEY_SAMPLE + i, points[i].getSample()); } propertyMap.store(file, "BEAM Colour Palette Definition File"); /*I18N*/ }
public static void transferConnectionData(PropertyMap propertyMap, ConnectionConfigData connectionConfigData) { ProxyConfig proxyConfig = new ProxyConfig(); connectionConfigData.setProxyConfig(proxyConfig); connectionConfigData.setRepositoryUrl(System.getProperty(SYS_KEY_BEAM_REPOSITORY_URL, "")); connectionConfigData.setProxyUsed(propertyMap.getPropertyBool(KEY_BEAM_REPOSITORY_PROXY_USED, false)); proxyConfig.setHost(propertyMap.getPropertyString(KEY_BEAM_REPOSITORY_PROXY_HOST)); proxyConfig.setPort(propertyMap.getPropertyInt(KEY_BEAM_REPOSITORY_PROXY_PORT)); proxyConfig.setAuthorizationUsed(propertyMap.getPropertyBool(KEY_BEAM_REPOSITORY_PROXY_AUTH_USED)); proxyConfig.setUsername(propertyMap.getPropertyString(KEY_BEAM_REPOSITORY_PROXY_USERNAME)); proxyConfig.setScrambledPassword(propertyMap.getPropertyString(KEY_BEAM_REPOSITORY_PROXY_PASSWORD)); } }
@Test public void testValidation() { final PropertyMap map = new PropertyMap(); map.setPropertyString("historyItem.0", "one"); map.setPropertyString("historyItem.1", "two"); map.setPropertyString("historyItem.2", "three"); final UserInputHistory history = new UserInputHistory(3, "historyItem") { @Override protected boolean isValidItem(String item) { return "two".equals(item); } }; history.initBy(map); final HistoryComboBoxModel model = new HistoryComboBoxModel(history); assertEquals(1, model.getSize()); assertEquals("two", model.getElementAt(0)); }
public static void transferConnectionData(ConnectionConfigData connectionConfigData, PropertyMap propertyMap) { ProxyConfig proxyConfig = connectionConfigData.getProxyConfig(); propertyMap.setPropertyBool(KEY_BEAM_REPOSITORY_PROXY_USED, connectionConfigData.isProxyUsed()); propertyMap.setPropertyString(KEY_BEAM_REPOSITORY_PROXY_HOST, proxyConfig.getHost()); propertyMap.setPropertyInt(KEY_BEAM_REPOSITORY_PROXY_PORT, proxyConfig.getPort()); propertyMap.setPropertyBool(KEY_BEAM_REPOSITORY_PROXY_AUTH_USED, proxyConfig.isAuthorizationUsed()); propertyMap.setPropertyString(KEY_BEAM_REPOSITORY_PROXY_USERNAME, proxyConfig.getUsername()); propertyMap.setPropertyString(KEY_BEAM_REPOSITORY_PROXY_PASSWORD, proxyConfig.getScrambledPassword()); }
@Test public void testSaveHistory() { final HistoryComboBoxModel model = new HistoryComboBoxModel(new UserInputHistory(3, "historyItem")); model.setSelectedItem("one"); model.setSelectedItem("two"); final PropertyMap map = new PropertyMap(); model.getHistory().copyInto(map); assertEquals("two", map.getPropertyString("historyItem.0")); assertEquals("one", map.getPropertyString("historyItem.1")); assertEquals("", map.getPropertyString("historyItem.2")); model.setSelectedItem("three"); model.getHistory().copyInto(map); assertEquals("three", map.getPropertyString("historyItem.0")); assertEquals("two", map.getPropertyString("historyItem.1")); assertEquals("one", map.getPropertyString("historyItem.2")); } }
/** * Tests functionality of set and getPropertyInt */ public void testSetGetPropertyInt() { PropertyMap prop = new PropertyMap(); // "a" is not in the set assertEquals(0, prop.getPropertyInt("a")); // test default assertEquals(8, prop.getPropertyInt("a", 8)); assertEquals(null, prop.getPropertyInt("a", null)); assertEquals(new Integer(8), prop.getPropertyInt("a", new Integer(8))); // "b" is in the set and 23 prop.setPropertyInt("b", 23); assertEquals(23, prop.getPropertyInt("b")); assertEquals(23, prop.getPropertyInt("b", 43)); assertEquals(new Integer(23), prop.getPropertyInt("b", new Integer(43))); assertEquals(new Integer(23), prop.getPropertyInt("b", null)); }
public DefaultAppContext(String applicationName) { this(applicationName, new JFrame(applicationName), new ProductManager(), new PropertyMap()); }
configuration.getPropertyBool(GraticuleLayerType.PROPERTY_NAME_RES_AUTO, GraticuleLayerType.DEFAULT_RES_AUTO)); layerConfiguration.setValue(GraticuleLayerType.PROPERTY_NAME_RES_PIXELS, configuration.getPropertyInt(GraticuleLayerType.PROPERTY_NAME_RES_PIXELS, GraticuleLayerType.DEFAULT_RES_PIXELS)); layerConfiguration.setValue(GraticuleLayerType.PROPERTY_NAME_RES_LAT, configuration.getPropertyDouble(GraticuleLayerType.PROPERTY_NAME_RES_LAT, GraticuleLayerType.DEFAULT_RES_LAT)); layerConfiguration.setValue(GraticuleLayerType.PROPERTY_NAME_RES_LON, configuration.getPropertyDouble(GraticuleLayerType.PROPERTY_NAME_RES_LON, GraticuleLayerType.DEFAULT_RES_LON)); configuration.getPropertyColor(GraticuleLayerType.PROPERTY_NAME_LINE_COLOR, GraticuleLayerType.DEFAULT_LINE_COLOR)); layerConfiguration.setValue(GraticuleLayerType.PROPERTY_NAME_LINE_WIDTH, configuration.getPropertyDouble(GraticuleLayerType.PROPERTY_NAME_LINE_WIDTH, GraticuleLayerType.DEFAULT_LINE_WIDTH)); layerConfiguration.setValue(GraticuleLayerType.PROPERTY_NAME_LINE_TRANSPARENCY, configuration.getPropertyDouble( GraticuleLayerType.PROPERTY_NAME_LINE_TRANSPARENCY, GraticuleLayerType.DEFAULT_LINE_TRANSPARENCY)); layerConfiguration.setValue(GraticuleLayerType.PROPERTY_NAME_TEXT_ENABLED, configuration.getPropertyBool(GraticuleLayerType.PROPERTY_NAME_TEXT_ENABLED, GraticuleLayerType.DEFAULT_TEXT_ENABLED)); layerConfiguration.setValue(GraticuleLayerType.PROPERTY_NAME_TEXT_FG_COLOR, configuration.getPropertyColor(GraticuleLayerType.PROPERTY_NAME_TEXT_FG_COLOR, GraticuleLayerType.DEFAULT_TEXT_FG_COLOR)); layerConfiguration.setValue(GraticuleLayerType.PROPERTY_NAME_TEXT_BG_COLOR, configuration.getPropertyColor(GraticuleLayerType.PROPERTY_NAME_TEXT_BG_COLOR,
public void copyInto(PropertyMap propertyMap) { propertyMap.setPropertyInt(getLengthKey(), _maxNumEntries); for (int i = 0; i < 100; i++) { propertyMap.setPropertyString(getNumKey(i), null); } final String[] entries = getEntries(); if (entries != null) { for (int i = 0; i < entries.length; i++) { propertyMap.setPropertyString(getNumKey(i), entries[i]); } } }