org.artoflife.gui.paintable
Class PaintableIndividualPersistence

java.lang.Object
  |
  +--org.artoflife.gui.paintable.PaintableIndividualPersistence

public class PaintableIndividualPersistence
extends java.lang.Object

Utility responsible for saving/loading Individuals using a PaintablePhenotype to and from Files as a lores thumbnail or hires PNG image with a serialised copy of the Individual in PNG header as a tEXtEntry record of the tEXt metadata. The tEXtEntry record has an attribute called "keyword" set to "serialized_base64", and another attribute called "object" set to a base64 encoded serialised Individual.

The definition of hires and lores comes from UserPreferences. Which is a bad dependency.

Author:
Steve Meyfroidt
To do:
fix dependency between this and UserPreferences

Images are painted with anti-aliasing. This setup should probably be more overridable?, make Graphics config overridable


Method Summary
static Individual loadIndividual(java.io.File file)
           
static void saveIndividual(Individual individual, java.io.File file, boolean asThumbnail)
          Save an Individual with a PaintablePhenotype as a PNG file (see class comment).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

saveIndividual

public static void saveIndividual(Individual individual,
                                  java.io.File file,
                                  boolean asThumbnail)
                           throws java.io.IOException
Save an Individual with a PaintablePhenotype as a PNG file (see class comment). Writes a small blank image if the phenotype isn't paintable.

Parameters:
individual - to save
file - the save into
asThumbnail - whether to create a lores PNG from the Individual's PaintablePhenotype or a hires one
Throws:
java.io.IOException - on errors writing the file
java.lang.IllegalArgumentException - if individual or file is null

loadIndividual

public static Individual loadIndividual(java.io.File file)
                                 throws java.io.IOException
Parameters:
file - load from here
Returns:
an Individual deserialized from PNG metadata, or null if no serialized form in the image file. See class comment.
Throws:
java.io.IOException - on problems reading from file
java.lang.IllegalArgumentException - if file is null

artoflife pre0.1.0-dev

Copyright © 2002 the Art Of Life team. All Rights Reserved.