[Pixelle-commit] SF.net SVN: pixelle: [149] trunk/pixelle/src/com/mebigfatguy/pixelle
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2008-07-06 22:09:40
|
Revision: 149
http://pixelle.svn.sourceforge.net/pixelle/?rev=149&view=rev
Author: dbrosius
Date: 2008-07-06 15:09:40 -0700 (Sun, 06 Jul 2008)
Log Message:
-----------
load user algorithms
Modified Paths:
--------------
trunk/pixelle/src/com/mebigfatguy/pixelle/AlgorithmArchiver.java
trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleBundle.java
trunk/pixelle/src/com/mebigfatguy/pixelle/resources/pixelle.properties
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/AlgorithmArchiver.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/AlgorithmArchiver.java 2008-07-06 22:02:11 UTC (rev 148)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/AlgorithmArchiver.java 2008-07-06 22:09:40 UTC (rev 149)
@@ -18,11 +18,15 @@
*/
package com.mebigfatguy.pixelle;
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
+import javax.swing.JOptionPane;
import javax.swing.JPopupMenu;
import org.xml.sax.Attributes;
@@ -42,11 +46,8 @@
private static final String ALGORITHM = "algorithm";
private static final String COMPONENT = "component";
private static final String NAME = "name";
- private static final String RED = "red";
- private static final String GREEN = "green";
- private static final String BLUE = "blue";
- private static final String TRANSPARENCY = "transparency";
- private static final String SELECTION = "selection";
+ private static final String PIXELLE = "pixelle";
+ private static final String ALGORITHMS_FILE = "algorithms.xml";
private static AlgorithmArchiver archiver = new AlgorithmArchiver();
@@ -58,6 +59,7 @@
systemAlgorithms = new HashMap<String, Map<String, Map<PixelleComponent, String>>>();
userAlgorithms = new HashMap<String, Map<String, Map<PixelleComponent, String>>>();
loadSystemAlgorithms();
+ loadUserAlgorithms();
}
public static AlgorithmArchiver getArchiver() {
@@ -89,6 +91,20 @@
}
private void loadUserAlgorithms() {
+ InputStream is = null;
+ try {
+ File pixelleDir = new File(System.getProperty("user.home"), PIXELLE);
+ pixelleDir.mkdirs();
+ File algoFile = new File(pixelleDir, ALGORITHMS_FILE);
+ if (algoFile.exists() && algoFile.isFile()) {
+ is = new BufferedInputStream(new FileInputStream(algoFile));
+ parseAlgorithms(is, userAlgorithms);
+ }
+ } catch (Exception e) {
+ JOptionPane.showMessageDialog(null, e.getMessage());
+ } finally {
+ Closer.close(is);
+ }
}
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleBundle.java
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleBundle.java 2008-07-06 22:02:11 UTC (rev 148)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/PixelleBundle.java 2008-07-06 22:09:40 UTC (rev 149)
@@ -52,12 +52,14 @@
public static final String OPTIONS_ITEM = "menu.transform.options";
public static final String TRANSFORM_NEW_ITEM = "menu.transform.newwindow";
public static final String TRANSFORM_ITEM = "menu.transform.transform";
+ public static final String SAVE_ALGORITHM = "save.algorithm";
public static final String RED_FORMULA = "formula.red";
public static final String GREEN_FORMULA = "formula.green";
public static final String BLUE_FORMULA = "formula.blue";
public static final String TRANSPARENCY_FORMULA = "formula.transparency";
public static final String SELECTION_FORMULA = "formula.selection";
public static final String PIXEL_ALGORITHMS = "title.algorithms";
+ public static final String PIXEL_ALGORITHM = "label.algorithm";
public static final String RED_LABEL = "label.red";
public static final String GREEN_LABEL = "label.green";
public static final String BLUE_LABEL = "label.blue";
Modified: trunk/pixelle/src/com/mebigfatguy/pixelle/resources/pixelle.properties
===================================================================
--- trunk/pixelle/src/com/mebigfatguy/pixelle/resources/pixelle.properties 2008-07-06 22:02:11 UTC (rev 148)
+++ trunk/pixelle/src/com/mebigfatguy/pixelle/resources/pixelle.properties 2008-07-06 22:09:40 UTC (rev 149)
@@ -54,6 +54,8 @@
formula.selection = p[x,y].s
title.algorithms = Pixel Algorithms
+label.algorithm = Algorithm
+save.algorithm = Save
label.red = (Red)
label.green = (Green)
label.blue = (Blue)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|