[ocrfeeder] dataHolder: Delete trailing whitespaces
- From: Joaquim Manuel Pereira Rocha <jrocha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ocrfeeder] dataHolder: Delete trailing whitespaces
- Date: Thu, 1 Jul 2010 09:56:09 +0000 (UTC)
commit 6cf5943a423142080bc3b2d01b188ea126770de3
Author: Joaquim Rocha <jrocha igalia com>
Date: Thu Jul 1 10:52:06 2010 +0200
dataHolder: Delete trailing whitespaces
studio/dataHolder.py | 90 +++++++++++++++++++++++++-------------------------
1 files changed, 45 insertions(+), 45 deletions(-)
---
diff --git a/studio/dataHolder.py b/studio/dataHolder.py
index 27cc291..6918427 100644
--- a/studio/dataHolder.py
+++ b/studio/dataHolder.py
@@ -3,7 +3,7 @@
###########################################################################
# OCRFeeder - The complete OCR suite
# Copyright (C) 2009 Joaquim Rocha
-#
+#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
@@ -25,9 +25,9 @@ import gobject
from util.graphics import getImagePrintSize, getImageResolution
from util import TEXT_TYPE, IMAGE_TYPE, ALIGN_LEFT, lib
from pango import WEIGHT_NORMAL, STYLE_NORMAL
-
+
class TextData:
-
+
def __init__(self, face = 'Sans', size = 12, justification = ALIGN_LEFT, line_space = 0, letter_space = 0, style = STYLE_NORMAL, weight = WEIGHT_NORMAL):
self.face = face
self.size = size
@@ -37,18 +37,18 @@ class TextData:
self.style = style
self.weight = weight
self.angle = 0
-
+
def convertToDict(self):
- dictionary = lib.getDictFromVariables(['face', 'size', 'line_space',
+ dictionary = lib.getDictFromVariables(['face', 'size', 'line_space',
'letter_space', 'justification', 'angle'], self)
dictionary['style'] = repr(self.style).split(' ')[1].strip('PANGO_')
dictionary['weight'] = repr(self.weight).split(' ')[1].strip('PANGO_')
return {'TextData': dictionary}
class DataBox(gobject.GObject):
-
+
__gtype_name__ = 'DataBox'
-
+
__gsignals__ = {
'changed_x' : (gobject.SIGNAL_RUN_LAST,
gobject.TYPE_NONE,
@@ -69,7 +69,7 @@ class DataBox(gobject.GObject):
gobject.TYPE_NONE,
(gobject.TYPE_INT,))
}
-
+
def __init__(self, x = 0, y = 0, width = 0, height = 0, image = None, type = TEXT_TYPE, text = None):
super(DataBox, self).__init__()
self.x = x
@@ -80,104 +80,104 @@ class DataBox(gobject.GObject):
self.setType(type)
self.text_data = TextData()
self.text = text
-
+
def configTextData(self, face = 'Sans', size = 12, justification = ALIGN_LEFT, line_space = 1, letter_space = 1):
self.text_data = TextData(face, size, justification, line_space, letter_space)
-
+
def setX(self, new_x):
self.x = new_x
self.emit('changed_x', self.x)
-
+
def setY(self, new_y):
self.y = new_y
self.emit('changed_y', self.y)
-
+
def setWidth(self, new_width):
self.width = new_width
self.emit('changed_width', self.width)
-
+
def setHeight(self, new_height):
self.height = new_height
self.emit('changed_height', self.height)
-
+
def setImage(self, pixbuf):
self.image = graphics.convertPixbufToImage(pixbuf)
self.emit('changed_image', pixbuf)
-
+
def setType(self, new_type):
self.type = new_type
self.emit('changed_type', self.type)
-
+
def getType(self):
return self.type
-
+
def toogleType(self):
if self.type == TEXT_TYPE:
self.setType(IMAGE_TYPE)
else:
self.setType(TEXT_TYPE)
-
+
def setFontFace(self, font_face):
self.text_data.face = font_face
-
+
def setFontSize(self, font_size):
self.text_data.size = font_size
-
+
def setFontStyle(self, font_style):
self.text_data.style = font_style
-
+
def setFontWeight(self, font_weight):
self.text_data.weight = font_weight
-
+
def setText(self, text):
self.text = text
-
+
def getText(self):
return self.text
-
+
def setAngle(self, angle):
self.text_data.angle = angle
-
+
def getAngle(self):
return self.text_data.angle
-
+
def setTextAlign(self, align_option):
self.text_data.justification = align_option
-
+
def setLetterSpacing(self, spacing):
self.text_data.letter_space = spacing
-
+
def setLineSpacing(self, spacing):
self.text_data.line_space = spacing
-
+
def getX(self):
return self.x
-
+
def getY(self):
return self.y
-
+
def getWidth(self):
return self.width
-
+
def getHeight(self):
return self.height
-
+
def getBoundsPrintSize(self, resolution):
x_resolution, y_resolution = float(resolution[0]), float(resolution[1])
x, y, width, height = self.getX(), self.getY(), \
self.getWidth(), self.getHeight()
return x / x_resolution, y / y_resolution, width / x_resolution, height / y_resolution
-
+
def convertToDict(self):
- dictionary = lib.getDictFromVariables(['x', 'y', 'width',
+ dictionary = lib.getDictFromVariables(['x', 'y', 'width',
'height', 'type', 'text'], self)
dictionary['text_data'] = self.text_data.convertToDict()
return {'DataBox': dictionary}
-
-
-
+
+
+
class PageData:
-
+
def __init__(self, image_path, data_boxes = []):
image = Image.open(image_path)
self.pixel_width, self.pixel_height = image.size
@@ -185,21 +185,21 @@ class PageData:
self.setSize(getImagePrintSize(image))
self.resolution = getImageResolution(image)
self.data_boxes = data_boxes
-
+
def setSize(self, page_size):
self.width, self.height = page_size
self.resolution = self.pixel_width / self.width, self.pixel_height / self.height
-
+
def setResolution(self, new_resolution):
self.resolution = new_resolution
-
+
def convertToDict(self):
dictionary = lib.getDictFromVariables(['pixel_width', 'pixel_height', 'image_path', 'resolution'], self)
data_boxes_converted = [data_box.convertToDict() for data_box in self.data_boxes]
dictionary['data_boxes'] = data_boxes_converted
return {'PageData': dictionary}
-
-
+
+
def create_images_dict_from_liststore(list_store):
images_dict = {}
iter = list_store.get_iter_root()
@@ -208,4 +208,4 @@ def create_images_dict_from_liststore(list_store):
image_path = list_store.get_value(iter, 0)
images_dict[pixbuf] = image_path
iter = list_store.iter_next(iter)
- return images_dict
\ No newline at end of file
+ return images_dict
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]