aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPGeometryDataView.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-10-09 14:12:40 +0000
committerBibiko <bibiko@eva.mpg.de>2010-10-09 14:12:40 +0000
commit2206c9cdc5bea1552a0fbf66e7e9f310e7bdc880 (patch)
tree9ff31cbbe63f3027a4c716e51334276d3f912562 /Source/SPGeometryDataView.m
parentbfd2c744eb99057bba37f331672d828ba48f82f0 (diff)
downloadsequelpro-2206c9cdc5bea1552a0fbf66e7e9f310e7bdc880.tar.gz
sequelpro-2206c9cdc5bea1552a0fbf66e7e9f310e7bdc880.tar.bz2
sequelpro-2206c9cdc5bea1552a0fbf66e7e9f310e7bdc880.zip
• improved field editor sheet to support geometry fields
- additionally it shows the image - image can be saved as pdf if image is displayed via Save button; if text is selected the wkt string will be saved
Diffstat (limited to 'Source/SPGeometryDataView.m')
-rw-r--r--Source/SPGeometryDataView.m31
1 files changed, 27 insertions, 4 deletions
diff --git a/Source/SPGeometryDataView.m b/Source/SPGeometryDataView.m
index 95e6d2b7..95d9c7db 100644
--- a/Source/SPGeometryDataView.m
+++ b/Source/SPGeometryDataView.m
@@ -28,16 +28,22 @@
@implementation SPGeometryDataView
/**
- * Initialize SPGeometryDataView object
+ * Initialize SPGeometryDataView object with default targetDimension
*/
- (id)initWithCoordinates:(NSDictionary*)coord
{
+ return [self initWithCoordinates:coord targetDimension:400.0];
+}
+
+/**
+ * Initialize SPGeometryDataView object
+ */
+- (id)initWithCoordinates:(NSDictionary*)coord targetDimension:(CGFloat)targetDimension
+{
CGFloat maxDim;
- CGFloat targetDim = 400.0;
margin_offset = 10.0;
-
type = [coord objectForKey:@"type"];
coordinates = [coord objectForKey:@"coordinates"];
@@ -51,7 +57,7 @@
maxDim = (width > height) ? width : height;
if(maxDim != 0)
- zoom_factor = targetDim/maxDim;
+ zoom_factor = targetDimension/maxDim;
else
zoom_factor = 1.0;
@@ -224,6 +230,9 @@
}
}
+/**
+ * Return the geometry as NSImage by using targetDimension
+ */
- (NSImage*)thumbnailImage
{
@@ -244,6 +253,20 @@
}
/**
+ * Return PDF data of the geometry image
+ */
+- (NSData*)pdfData
+{
+ if(!type || ![type length] || !coordinates || ![coordinates count]) return nil;
+
+ NSSize mySize = self.bounds.size;
+ NSRect myBounds = [self bounds];
+
+ return [self dataWithPDFInsideRect:myBounds];
+
+}
+
+/**
* dealloc
*/
- (void)dealloc