Commits

Dmytro Kovalchuk committed 97142d6

Started work on issue 19. Refs issue 19

Comments (0)

Files changed (2)

compactFileFormat

+# HG changeset patch
+# Parent 56d56097978fa6520a0d86ac397d024ec0fcdebe
+File format compacted. Refs issue 19
+
+diff -r 56d56097978f -r 8552a71baf04 cross-stitch-fileservice-impl/src/main/java/net/anatolich/cstitch/schema/file/impl/DefaultCanvasReader.java
+--- a/cross-stitch-fileservice-impl/src/main/java/net/anatolich/cstitch/schema/file/impl/DefaultCanvasReader.java	Wed Apr 11 01:46:42 2012 +0300
++++ b/cross-stitch-fileservice-impl/src/main/java/net/anatolich/cstitch/schema/file/impl/DefaultCanvasReader.java	Wed Apr 11 01:55:02 2012 +0300
+@@ -15,7 +15,6 @@
+  */
+ package net.anatolich.cstitch.schema.file.impl;
+ 
+-import net.anatolich.cstitch.schema.file.format.api.FileReader;
+ import com.google.inject.Inject;
+ import java.awt.Color;
+ import java.io.DataInputStream;
+@@ -27,6 +26,7 @@
+ import net.anatolich.cstitch.schema.Canvas;
+ import net.anatolich.cstitch.schema.DefaultCanvas;
+ import net.anatolich.cstitch.schema.Legend;
++import net.anatolich.cstitch.schema.file.format.api.FileReader;
+ 
+ /**
+  * Reader of canvas file of default format.
+@@ -104,23 +104,9 @@
+         }
+     }
+ 
+-    private PaletteColor readBackgroundColor(DataInputStream is) throws IOException {
+-        Color color = readColor(is);
+-        String name = is.readUTF();
+-        PaletteColor backgroundColor = new PaletteColor(name, color);
+-        return backgroundColor;
+-    }
+-
+     private Color readColor(DataInputStream is) throws IOException {
+-        final int red = is.readInt();
+-        final int green = is.readInt();
+-        final int blue = is.readInt();
+-        
+-        assert red <= 255 && red >= 0: "Invalid red element: red=" + red;
+-        assert green <= 255 && green >= 0: "Invalid red element: red=" + green;
+-        assert blue <= 255 && blue >= 0: "Invalid red element: red=" + blue;
+-        
+-        Color color = new Color(red, green, blue);
++        final int rgb = is.readInt();
++        Color color = new Color(rgb);
+         return color;
+     }
+ 
+diff -r 56d56097978f -r 8552a71baf04 cross-stitch-fileservice-impl/src/main/java/net/anatolich/cstitch/schema/file/impl/DefaultCanvasWriter.java
+--- a/cross-stitch-fileservice-impl/src/main/java/net/anatolich/cstitch/schema/file/impl/DefaultCanvasWriter.java	Wed Apr 11 01:46:42 2012 +0300
++++ b/cross-stitch-fileservice-impl/src/main/java/net/anatolich/cstitch/schema/file/impl/DefaultCanvasWriter.java	Wed Apr 11 01:55:02 2012 +0300
+@@ -15,15 +15,14 @@
+  */
+ package net.anatolich.cstitch.schema.file.impl;
+ 
+-import net.anatolich.cstitch.schema.file.format.api.FileWriter;
+ import java.io.DataOutputStream;
+ import java.io.IOException;
+ import java.io.OutputStream;
+ import java.util.List;
+-import net.anatolich.cstitch.palette.api.Palette;
+ import net.anatolich.cstitch.palette.api.PaletteColor;
+ import net.anatolich.cstitch.schema.Canvas;
+ import net.anatolich.cstitch.schema.Legend;
++import net.anatolich.cstitch.schema.file.format.api.FileWriter;
+ 
+ /**
+  * Writer of canvas file of default format.
+@@ -68,9 +67,7 @@
+     }
+ 
+     private void writePaletteColor(final PaletteColor color, final DataOutputStream stream) throws IOException {
+-        stream.writeInt(color.getRed());
+-        stream.writeInt(color.getGreen());
+-        stream.writeInt(color.getBlue());
++        stream.writeInt(color.getRGB());
+         stream.writeUTF(color.getPalette().getName());
+         stream.writeUTF(color.getName());
+     }
+compactFileFormat
 # Placed by Bitbucket