Search in sources :

Example 1 with LinearGradient

use of org.gephi.appearance.plugin.RankingElementColorTransformer.LinearGradient in project gephi by gephi.

the class RecentPalettes method retrieve.

private void retrieve() {
    gradients.clear();
    Preferences prefs = getPreferences();
    for (int i = 0; i < maxSize; i++) {
        byte[] cols = prefs.getByteArray(COLORS + i, null);
        byte[] poss = prefs.getByteArray(POSITIONS + i, null);
        if (cols != null && poss != null) {
            try {
                Color[] colors = deserializeColors(cols);
                float[] posisitons = deserializePositions(poss);
                LinearGradient linearGradient = new LinearGradient(colors, posisitons);
                gradients.addLast(linearGradient);
            } catch (Exception e) {
                e.printStackTrace();
            }
        } else {
            break;
        }
    }
}
Also used : LinearGradient(org.gephi.appearance.plugin.RankingElementColorTransformer.LinearGradient) Color(java.awt.Color) NbPreferences(org.openide.util.NbPreferences) Preferences(java.util.prefs.Preferences) BackingStoreException(java.util.prefs.BackingStoreException)

Example 2 with LinearGradient

use of org.gephi.appearance.plugin.RankingElementColorTransformer.LinearGradient in project gephi by gephi.

the class RecentPalettes method store.

private void store() {
    Preferences prefs = getPreferences();
    // clear the backing store
    try {
        prefs.clear();
    } catch (BackingStoreException ex) {
    }
    int i = 0;
    for (LinearGradient gradient : gradients) {
        try {
            prefs.putByteArray(COLORS + i, serializeColors(gradient.getColors()));
            prefs.putByteArray(POSITIONS + i, serializePositions(gradient.getPositions()));
        } catch (Exception e) {
            e.printStackTrace();
        }
        i++;
    }
}
Also used : LinearGradient(org.gephi.appearance.plugin.RankingElementColorTransformer.LinearGradient) BackingStoreException(java.util.prefs.BackingStoreException) NbPreferences(org.openide.util.NbPreferences) Preferences(java.util.prefs.Preferences) BackingStoreException(java.util.prefs.BackingStoreException)

Example 3 with LinearGradient

use of org.gephi.appearance.plugin.RankingElementColorTransformer.LinearGradient in project gephi by gephi.

the class RecentPalettes method add.

public void add(LinearGradient gradient) {
    //Remove the old
    gradients.remove(gradient);
    // add to the top
    gradients.push(new LinearGradient(gradient.getColors(), gradient.getPositions()));
    while (gradients.size() > maxSize) {
        gradients.removeLast();
    }
    store();
}
Also used : LinearGradient(org.gephi.appearance.plugin.RankingElementColorTransformer.LinearGradient)

Aggregations

LinearGradient (org.gephi.appearance.plugin.RankingElementColorTransformer.LinearGradient)3 BackingStoreException (java.util.prefs.BackingStoreException)2 Preferences (java.util.prefs.Preferences)2 NbPreferences (org.openide.util.NbPreferences)2 Color (java.awt.Color)1