]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/TextNode.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.scenegraph / src / org / simantics / scenegraph / g2d / nodes / TextNode.java
index 15076e6295ccd7cba71bae4121b4d3a8dfd3fe53..b7bd4810091bede5a01d65a891bedcca51c53719 100644 (file)
@@ -1,37 +1,37 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
- * in Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
 package org.simantics.scenegraph.g2d.nodes;
 
-import java.awt.Color;\r
-import java.awt.Font;\r
-import java.awt.FontMetrics;\r
-import java.awt.Graphics2D;\r
-import java.awt.geom.AffineTransform;\r
-import java.awt.geom.Point2D;\r
-import java.awt.geom.Rectangle2D;\r
-import java.io.IOException;\r
-\r
-import org.simantics.scenegraph.ExportableWidget.OutputWidget;\r
-import org.simantics.scenegraph.g2d.G2DNode;\r
-import org.simantics.scenegraph.g2d.G2DPDFRenderingHints;\r
-\r
-import com.lowagie.text.DocumentException;\r
-import com.lowagie.text.Element;\r
-import com.lowagie.text.Rectangle;\r
-import com.lowagie.text.pdf.FontMapper;\r
-import com.lowagie.text.pdf.PdfFormField;\r
-import com.lowagie.text.pdf.PdfWriter;\r
-import com.lowagie.text.pdf.TextField;\r
-\r
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics2D;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+import java.io.IOException;
+
+import org.simantics.scenegraph.ExportableWidget.OutputWidget;
+import org.simantics.scenegraph.g2d.G2DNode;
+import org.simantics.scenegraph.g2d.G2DPDFRenderingHints;
+
+import com.lowagie.text.DocumentException;
+import com.lowagie.text.Element;
+import com.lowagie.text.Rectangle;
+import com.lowagie.text.pdf.FontMapper;
+import com.lowagie.text.pdf.PdfFormField;
+import com.lowagie.text.pdf.PdfWriter;
+import com.lowagie.text.pdf.TextField;
+
 @OutputWidget("text")
 public class TextNode extends G2DNode {
 
@@ -57,22 +57,22 @@ public class TextNode extends G2DNode {
         this.text = text;
     }
     
-    public String getText() {\r
-        return this.text;\r
-    }\r
-\r
+    public String getText() {
+        return this.text;
+    }
+
     @SyncField("color")
     public void setColor(Color color) {
         this.color = color;
     }
 
     @Override
-    public void render(Graphics2D g) {\r
-        if (text == null || bounds == null || font == null || color == null)\r
-            return;\r
-        \r
-//        PdfWriter writer = (PdfWriter) g.getRenderingHint(G2DPDFRenderingHints.KEY_PDF_WRITER);\r
-//        if ( writer == null ) {\r
+    public void render(Graphics2D g) {
+        if (text == null || bounds == null || font == null || color == null)
+            return;
+        
+//        PdfWriter writer = (PdfWriter) g.getRenderingHint(G2DPDFRenderingHints.KEY_PDF_WRITER);
+//        if ( writer == null ) {
                // Write to Graphics2D
                g.setFont(font);
                g.setColor(color);
@@ -80,62 +80,62 @@ public class TextNode extends G2DNode {
                FontMetrics fm =        g.getFontMetrics(font);
                Rectangle2D rect =      fm.getStringBounds(text, g);
                float x = (float) ((bounds.getWidth()  - rect.getWidth())/2 + bounds.getMinX());
-               float y = (float) ((bounds.getHeight() - rect.getHeight())/2 + bounds.getMinY());\r
-               \r
-               AffineTransform at = g.getTransform();\r
+               float y = (float) ((bounds.getHeight() - rect.getHeight())/2 + bounds.getMinY());
+               
+               AffineTransform at = g.getTransform();
                g.transform(getTransform());
-               g.drawString(text, x, (float)(y+rect.getHeight()));\r
-               g.setTransform(at);\r
-//        } else {\r
-               /*\r
-                       try {\r
-                       // Write to PDF\r
-                   FontMapper mapper = (FontMapper) g.getRenderingHint(G2DPDFRenderingHints.KEY_PDF_FONTMAPPER);\r
-                   //text.setBorderStyle(PdfBorderDictionary.STYLE_BEVELED);\r
-                   AffineTransform at = g.getTransform();\r
-                       FontMetrics fm =        g.getFontMetrics(font);\r
-                       Rectangle2D rect =      fm.getStringBounds(text, g);\r
-                       float x = (float) ((bounds.getWidth()  - rect.getWidth())/2 + bounds.getMinX());\r
-                       float y = (float) ((bounds.getHeight() - rect.getHeight())/2 + bounds.getMinY());\r
-                       \r
-                   Point2D pt1 = at.transform(new Point2D.Float(x, y+(float)rect.getHeight()), null);\r
-                   Point2D pt2 = at.transform(new Point2D.Float(x+(float)rect.getWidth(), y), null);\r
-                       Rectangle rectangle = new Rectangle(\r
-                                       (float) pt1.getX(), \r
-                                       (float) pt1.getY(), \r
-                                       (float) pt2.getX(), \r
-                                       (float) pt2.getY()); \r
-                   TextField text = new TextField(writer, rectangle, "approvedBy");\r
-                   text.setText(this.text);\r
-                   text.setFont(mapper.awtToPdf(font));\r
-                   text.setFontSize(0);\r
-                   text.setAlignment(Element.ALIGN_LEFT);\r
-                   text.setRotation(90);\r
-                   text.setOptions(TextField.READ_ONLY);\r
-                   PdfFormField field = text.getTextField();\r
-                   writer.addAnnotation(field);\r
-                       } catch (IOException e) {\r
-                               e.printStackTrace();\r
-                       } catch (DocumentException e) {\r
-                               e.printStackTrace();\r
-                       }\r
-               */\r
+               g.drawString(text, x, (float)(y+rect.getHeight()));
+               g.setTransform(at);
+//        } else {
+               /*
+                       try {
+                       // Write to PDF
+                   FontMapper mapper = (FontMapper) g.getRenderingHint(G2DPDFRenderingHints.KEY_PDF_FONTMAPPER);
+                   //text.setBorderStyle(PdfBorderDictionary.STYLE_BEVELED);
+                   AffineTransform at = g.getTransform();
+                       FontMetrics fm =        g.getFontMetrics(font);
+                       Rectangle2D rect =      fm.getStringBounds(text, g);
+                       float x = (float) ((bounds.getWidth()  - rect.getWidth())/2 + bounds.getMinX());
+                       float y = (float) ((bounds.getHeight() - rect.getHeight())/2 + bounds.getMinY());
+                       
+                   Point2D pt1 = at.transform(new Point2D.Float(x, y+(float)rect.getHeight()), null);
+                   Point2D pt2 = at.transform(new Point2D.Float(x+(float)rect.getWidth(), y), null);
+                       Rectangle rectangle = new Rectangle(
+                                       (float) pt1.getX(), 
+                                       (float) pt1.getY(), 
+                                       (float) pt2.getX(), 
+                                       (float) pt2.getY()); 
+                   TextField text = new TextField(writer, rectangle, "approvedBy");
+                   text.setText(this.text);
+                   text.setFont(mapper.awtToPdf(font));
+                   text.setFontSize(0);
+                   text.setAlignment(Element.ALIGN_LEFT);
+                   text.setRotation(90);
+                   text.setOptions(TextField.READ_ONLY);
+                   PdfFormField field = text.getTextField();
+                   writer.addAnnotation(field);
+                       } catch (IOException e) {
+                               e.printStackTrace();
+                       } catch (DocumentException e) {
+                               e.printStackTrace();
+                       }
+               */
 //        }
     }
 
 //    @Override
 //    public Rectangle2D getBoundsInLocal() {
 //        return bounds;
-//    }\r
-    \r
-    @Override\r
-    public Rectangle2D getBoundsInLocal() {\r
-        return bounds;\r
-    }\r
-    \r
-    @Override\r
-    public Rectangle2D getBounds() {\r
-        return null;\r
-    }\r
+//    }
+    
+    @Override
+    public Rectangle2D getBoundsInLocal() {
+        return bounds;
+    }
+    
+    @Override
+    public Rectangle2D getBounds() {
+        return null;
+    }
     
 }