/** Saves the settings to a file. * @throws IOException if the file could not be saved. */ public void save (File file) throws IOException { PrintStream out = new PrintStream(file, "UTF-8"); out.println("font.name=" + fontName); out.println("font.size=" + fontSize); out.println("font.bold=" + bold); out.println("font.italic=" + italic); out.println(); out.println("font2.file=" + font2File); out.println("font2.use=" + font2Active); out.println(); out.println("pad.top=" + paddingTop); out.println("pad.right=" + paddingRight); out.println("pad.bottom=" + paddingBottom); out.println("pad.left=" + paddingLeft); out.println("pad.advance.x=" + paddingAdvanceX); out.println("pad.advance.y=" + paddingAdvanceY); out.println(); out.println("glyph.native.rendering=" + nativeRendering); out.println("glyph.page.width=" + glyphPageWidth); out.println("glyph.page.height=" + glyphPageHeight); out.println("glyph.text=" + glyphText); out.println(); for (Iterator iter = effects.iterator(); iter.hasNext();) { ConfigurableEffect effect = (ConfigurableEffect)iter.next(); out.println("effect.class=" + effect.getClass().getName()); for (Iterator iter2 = effect.getValues().iterator(); iter2.hasNext();) { Value value = (Value)iter2.next(); out.println("effect." + value.getName() + "=" + value.getString()); } out.println(); } out.close(); }
/** Returns a value that represents a color. */ static public Value colorValue (String name, Color currentValue) { return new DefaultValue(name, EffectUtil.toString(currentValue)) { public void showDialog () { Color newColor = JColorChooser.showDialog(null, "Choose a color", EffectUtil.fromString(value)); if (newColor != null) value = EffectUtil.toString(newColor); } public Object getObject () { return EffectUtil.fromString(value); } }; }
/** Returns a value that represents an int. */ static public Value intValue (String name, final int currentValue, final String description) { return new DefaultValue(name, String.valueOf(currentValue)) { public void showDialog () { JSpinner spinner = new JSpinner(new SpinnerNumberModel(currentValue, Short.MIN_VALUE, Short.MAX_VALUE, 1)); if (showValueDialog(spinner, description)) value = String.valueOf(spinner.getValue()); } public Object getObject () { return Integer.valueOf(value); } }; }
/** Returns a value that represents a float, from 0 to 1 (inclusive). */ static public Value floatValue (String name, final float currentValue, final float min, final float max, final String description) { return new DefaultValue(name, String.valueOf(currentValue)) { public void showDialog () { JSpinner spinner = new JSpinner(new SpinnerNumberModel(currentValue, min, max, 0.1f)); if (showValueDialog(spinner, description)) value = String.valueOf(((Double)spinner.getValue()).floatValue()); } public Object getObject () { return Float.valueOf(value); } }; }
/** Returns a value that represents a boolean. */ static public Value booleanValue (String name, final boolean currentValue, final String description) { return new DefaultValue(name, String.valueOf(currentValue)) { public void showDialog () { JCheckBox checkBox = new JCheckBox(); checkBox.setSelected(currentValue); if (showValueDialog(checkBox, description)) value = String.valueOf(checkBox.isSelected()); } public Object getObject () { return Boolean.valueOf(value); } }; }
public void updateValues () { prefs.put("foreground", EffectUtil.toString(colorEffect.getColor())); valuesPanel.removeAll(); values = effect.getValues(); for (Iterator iter = values.iterator(); iter.hasNext();) addValue((Value)iter.next()); }
/** Saves the settings to a file. * @throws IOException if the file could not be saved. */ public void save (File file) throws IOException { PrintStream out = new PrintStream(new FileOutputStream(file)); out.println("font.name=" + fontName); out.println("font.size=" + fontSize); out.println("font.bold=" + bold); out.println("font.italic=" + italic); out.println(); out.println("pad.top=" + paddingTop); out.println("pad.right=" + paddingRight); out.println("pad.bottom=" + paddingBottom); out.println("pad.left=" + paddingLeft); out.println("pad.advance.x=" + paddingAdvanceX); out.println("pad.advance.y=" + paddingAdvanceY); out.println(); out.println("glyph.native.rendering=" + nativeRendering); out.println("glyph.page.width=" + glyphPageWidth); out.println("glyph.page.height=" + glyphPageHeight); out.println("glyph.text=" + glyphText); out.println(); for (Iterator iter = effects.iterator(); iter.hasNext();) { ConfigurableEffect effect = (ConfigurableEffect)iter.next(); out.println("effect.class=" + effect.getClass().getName()); for (Iterator iter2 = effect.getValues().iterator(); iter2.hasNext();) { Value value = (Value)iter2.next(); out.println("effect." + value.getName() + "=" + value.getString()); } out.println(); } out.close(); }
/** Saves the settings to a file. * @throws IOException if the file could not be saved. */ public void save (File file) throws IOException { PrintStream out = new PrintStream(new FileOutputStream(file)); out.println("font.size=" + fontSize); out.println("font.bold=" + bold); out.println("font.italic=" + italic); out.println(); out.println("pad.top=" + paddingTop); out.println("pad.right=" + paddingRight); out.println("pad.bottom=" + paddingBottom); out.println("pad.left=" + paddingLeft); out.println("pad.advance.x=" + paddingAdvanceX); out.println("pad.advance.y=" + paddingAdvanceY); out.println(); out.println("glyph.native.rendering=" + nativeRendering); out.println("glyph.page.width=" + glyphPageWidth); out.println("glyph.page.height=" + glyphPageHeight); out.println("glyph.text=" + glyphText); out.println(); for (Iterator iter = effects.iterator(); iter.hasNext();) { ConfigurableEffect effect = (ConfigurableEffect)iter.next(); out.println("effect.class=" + effect.getClass().getName()); for (Iterator iter2 = effect.getValues().iterator(); iter2.hasNext();) { Value value = (Value)iter2.next(); out.println("effect." + value.getName() + "=" + value.getString()); } out.println(); } out.close(); }