174 lines
3.7 KiB
Plaintext
174 lines
3.7 KiB
Plaintext
@startuml
|
|
skinparam packageStyle rectangle
|
|
skinparam classAttributeIconSize 0
|
|
|
|
|
|
' ============================
|
|
' PACKAGE mimage
|
|
' ============================
|
|
package mimage {
|
|
|
|
class Pixel {
|
|
- int r
|
|
- int g
|
|
- int b
|
|
+ Pixel(int r, int g, int b)
|
|
+ int getR()
|
|
+ int getG()
|
|
+ int getB()
|
|
+ void setR(int r)
|
|
+ void setG(int g)
|
|
+ void setB(int b)
|
|
}
|
|
|
|
class RGBImage {
|
|
- int width
|
|
- int height
|
|
- Pixel[][] pixels
|
|
+ RGBImage(int width, int height)
|
|
+ int getWidth()
|
|
+ int getHeight()
|
|
+ Pixel getPixel(int x, int y)
|
|
+ void setPixel(int x, int y, Pixel p)
|
|
}
|
|
|
|
}
|
|
|
|
' ============================
|
|
' PACKAGE mhuffman
|
|
' ============================
|
|
package mhuffman {
|
|
|
|
class FrequencyTable {
|
|
- int[] freqR
|
|
- int[] freqG
|
|
- int[] freqB
|
|
+ FrequencyTable()
|
|
+ void computeFromImage(RGBImage img)
|
|
+ int[] getRed()
|
|
+ int[] getGreen()
|
|
+ int[] getBlue()
|
|
}
|
|
|
|
class HuffmanNode {
|
|
+ int value
|
|
+ int frequency
|
|
+ HuffmanNode left
|
|
+ HuffmanNode right
|
|
+ boolean isLeaf()
|
|
}
|
|
|
|
class HuffmanTree {
|
|
- HuffmanNode root
|
|
+ HuffmanTree(FrequencyTable freq, char component)
|
|
+ Map<Integer,String> generateCodes()
|
|
}
|
|
|
|
class CanonicalCode {
|
|
- Map<Integer,Integer> codeLengths
|
|
- Map<Integer,String> canonicalCodes
|
|
+ CanonicalCode(Map<Integer,String> huffmanCodes)
|
|
+ String getCode(int value)
|
|
+ int getLength(int value)
|
|
}
|
|
|
|
FrequencyTable --> RGBImage
|
|
HuffmanTree --> HuffmanNode
|
|
CanonicalCode --> HuffmanTree
|
|
|
|
}
|
|
|
|
' ============================
|
|
' PACKAGE util
|
|
' ============================
|
|
package util {
|
|
|
|
class BitInputStream {
|
|
- InputStream in
|
|
- int currentByte
|
|
- int bitPosition
|
|
+ BitInputStream(InputStream in)
|
|
+ int readBit()
|
|
+ int readBits(int n)
|
|
+ void close()
|
|
}
|
|
|
|
class BitOutputStream {
|
|
- OutputStream out
|
|
- int currentByte
|
|
- int bitCount
|
|
+ BitOutputStream(OutputStream out)
|
|
+ void writeBit(int bit)
|
|
+ void writeBits(int value, int n)
|
|
+ void flush()
|
|
+ void close()
|
|
}
|
|
|
|
class ByteUtils {
|
|
+ static int toInt(byte high, byte low)
|
|
+ static byte[] toBytes(int value)
|
|
}
|
|
|
|
class FileUtils {
|
|
+ static boolean isPIFFile(File f)
|
|
+ static byte[] readBinaryFile(String path)
|
|
}
|
|
|
|
}
|
|
|
|
' ============================
|
|
' PACKAGE vconverter
|
|
' ============================
|
|
package vconverter {
|
|
|
|
class ConverterWindow {
|
|
+ void setImagePreview(RGBImage img)
|
|
+ void setFrequencyTable(int[] r, int[] g, int[] b)
|
|
+ void setHuffmanTable(Map<Integer,String> red,
|
|
Map<Integer,String> green,
|
|
Map<Integer,String> blue)
|
|
+ void setCanonicalTable(CanonicalCode r, CanonicalCode g, CanonicalCode b)
|
|
}
|
|
|
|
class PreviewPanel {
|
|
- RGBImage image
|
|
+ void setImage(RGBImage img)
|
|
}
|
|
|
|
class FrequencyTablePanel {
|
|
+ void updateFrequencies(int[] r, int[] g, int[] b)
|
|
}
|
|
|
|
class CodeTablePanel {
|
|
+ void updateCodes(Map<Integer,String> hR,
|
|
Map<Integer,String> hG,
|
|
Map<Integer,String> hB,
|
|
CanonicalCode cR,
|
|
CanonicalCode cG,
|
|
CanonicalCode cB)
|
|
}
|
|
|
|
ConverterWindow --> PreviewPanel
|
|
ConverterWindow --> FrequencyTablePanel
|
|
ConverterWindow --> CodeTablePanel
|
|
|
|
}
|
|
|
|
' ============================
|
|
' CONTROLLER (Sprint 1)
|
|
' ============================
|
|
class ConverterController {
|
|
+ void loadImage(String path)
|
|
+ void computeFrequencies()
|
|
+ void computeHuffman()
|
|
+ void computeCanonical()
|
|
+ void saveAsPIF(String path) 'encore vide pour Sprint 1
|
|
}
|
|
|
|
ConverterController --> RGBImage
|
|
ConverterController --> FrequencyTable
|
|
ConverterController --> HuffmanTree
|
|
ConverterController --> CanonicalCode
|
|
|
|
@enduml
|