Revision: 5666
          http://sourceforge.net/p/jump-pilot/code/5666
Author:   michaudm
Date:     2018-01-07 21:02:59 +0000 (Sun, 07 Jan 2018)
Log Message:
-----------
Several corrections in the block tools of the CAD extension

Modified Paths:
--------------
    plug-ins/CADExtension/trunk/build.xml
    
plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/annotation/TextPanel.java
    
plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/BlockCellRenderer.java
    
plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/BlockPanel.java
    
plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/BlockUtils.java
    
plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/DrawBlockPlugIn.java
    
plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/DrawBlockTool.java
    
plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/DrawOrientedBlockPlugIn.java
    
plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/DrawOrientedBlockTool.java
    
plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/ImageCellRenderer.java
    
plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/SaveBlockPlugIn.java
    
plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/language/cadtoolbox_fr.properties

Added Paths:
-----------
    
plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/BlockCell.java

Modified: plug-ins/CADExtension/trunk/build.xml
===================================================================
--- plug-ins/CADExtension/trunk/build.xml       2018-01-05 13:34:20 UTC (rev 
5665)
+++ plug-ins/CADExtension/trunk/build.xml       2018-01-07 21:02:59 UTC (rev 
5666)
@@ -20,7 +20,7 @@
     <!-- Versions
     0.5 : first version built from ant
     -->
-    <property name="version" value="0.5" />
+    <property name="version" value="0.6" />
     
     <!-- =================================================================== 
-->
     <!-- Defines the classpath used for compilation and test.                
-->

Modified: 
plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/annotation/TextPanel.java
===================================================================
--- 
plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/annotation/TextPanel.java
        2018-01-05 13:34:20 UTC (rev 5665)
+++ 
plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/annotation/TextPanel.java
        2018-01-07 21:02:59 UTC (rev 5666)
@@ -78,8 +78,8 @@
         text_panel_jlabel2 = new JLabel(
                 
I18NPlug.getI18N("org.openjump.core.ui.plugins.block.dialog-dimension"));
         text_panel_jlabel2.setToolTipText(gedtDescription());
-        FormUtils.addRowInGBL(text_panel, 1, 0, null, text_panel_jlabel1,
-                textRotationSpinner, text_panel_jlabel2, textDimensionSpinner);
+        //FormUtils.addRowInGBL(text_panel, 1, 0, null, text_panel_jlabel1,
+        //        textRotationSpinner, text_panel_jlabel2, 
textDimensionSpinner);
         AddTextPlugIn add = new AddTextPlugIn();
         ChangeTextPlugIn change = new ChangeTextPlugIn();
 

Added: 
plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/BlockCell.java
===================================================================
--- 
plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/BlockCell.java 
                            (rev 0)
+++ 
plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/BlockCell.java 
    2018-01-07 21:02:59 UTC (rev 5666)
@@ -0,0 +1,153 @@
+package org.openjump.advancedtools.block;
+
+import com.vividsolutions.jts.geom.Coordinate;
+import com.vividsolutions.jts.geom.Envelope;
+import com.vividsolutions.jts.geom.Geometry;
+import com.vividsolutions.jts.io.ParseException;
+import com.vividsolutions.jts.io.WKTReader;
+import com.vividsolutions.jump.I18N;
+import com.vividsolutions.jump.workbench.ui.renderer.java2D.Java2DConverter;
+import org.openjump.core.geomutils.Circle;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.geom.NoninvertibleTransformException;
+import java.awt.geom.Point2D;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.Scanner;
+
+/**
+ * Thin wrapper containing the definition of a block (geometry), and how to 
show it
+ * in a ComboBox (name and icon).
+ */
+public class BlockCell {
+
+
+  public static BlockCell CIRCLE = new BlockCell(
+          I18N.get("deejump.ui.style.RenderingStylePanel.circle"),
+          new Circle(new Coordinate(0, 0), 8).getPoly());
+  public static BlockCell TRIANGLE = new BlockCell(
+          I18N.get("deejump.ui.style.RenderingStylePanel.triangle"),
+          "POLYGON((0 0, 16 0, 8 13.85, 0 0))");
+  public static BlockCell SQUARE = new BlockCell(
+          I18N.get("deejump.ui.style.RenderingStylePanel.square"),
+          "POLYGON((0 0, 16 0, 16 16, 0 16,  0 0))");
+  public static BlockCell CROSS = new BlockCell(
+          I18N.get("deejump.ui.style.RenderingStylePanel.cross"),
+          "POLYGON((5 0, 10 0, 10 5, 15 5, 15 10, 10 10, 10 15, 5 15, 5 10, 0 
10, 0 5, 5 5, 5 0))");
+  public static BlockCell STAR = new BlockCell(
+          I18N.get("deejump.ui.style.RenderingStylePanel.star"),
+          "POLYGON((4 6, 1 6, 3 4, 2 1, 5 3, 8 1, 7 4, 9 6, 6 6, 5 9, 4 6))");
+
+
+  private String name;
+  private Geometry geometry;
+  private Icon icon;
+
+  BlockCell(String name, Geometry geometry) {
+    try {
+      this.name = name;
+      this.geometry = geometry;
+      this.icon = createIcon(geometry);
+    } catch (NoninvertibleTransformException e) {}
+  }
+
+  BlockCell(String name, String wkt) {
+    try {
+      this.name = name;
+      this.geometry = new WKTReader().read(wkt);
+      this.icon = createIcon(geometry);
+    }
+    catch (NoninvertibleTransformException e) {}
+    catch (ParseException e) {}
+  }
+
+  BlockCell(File file) throws IOException, ParseException, 
NoninvertibleTransformException {
+    if (!file.isFile()) throw new IOException(file.getName() + " is not a 
valid file");
+    String fileName = file.getName();
+    if (!fileName.toUpperCase().endsWith(".WKT")) throw new 
IOException(fileName + " is not a valid filename for a WKT");
+    name = fileName.substring(0, fileName.lastIndexOf('.'));
+    String fileContent = readFile(file);
+    String segments[] = fileContent.split(":"); // Split into segments using : 
as separator
+    String wkt = segments[segments.length - 1]; // Grab the last segment
+    geometry = new WKTReader().read(wkt);
+    icon = createIcon(geometry);
+  }
+
+  public String toString() {
+    return name;
+  }
+
+  public Geometry getGeometry() {
+    return geometry;
+  }
+
+  public Icon getIcon() {
+    return icon;
+  }
+
+  private String readFile(File file) throws FileNotFoundException {
+    StringBuilder fileContents = new StringBuilder((int) file.length());
+    Scanner scanner = new Scanner(file);
+    String lineSeparator = System.getProperty("line.separator");
+    try {
+      while (scanner.hasNextLine()) {
+        fileContents.append(scanner.nextLine());
+        if (scanner.hasNextLine()) fileContents.append(lineSeparator);
+      }
+      return fileContents.toString();
+    } finally {
+      scanner.close();
+    }
+  }
+
+  /**
+   * Returns the Geometry as a Shape centered on the Geometry centroid
+   * @param geometry to convert
+   * @return a awt.Shape representing the Geometry
+   * @throws NoninvertibleTransformException
+   */
+  public static Shape getShape(Geometry geometry) throws 
NoninvertibleTransformException {
+    final Coordinate c = geometry.getCentroid().getCoordinate();
+    Java2DConverter java2DConverter = new Java2DConverter(new 
Java2DConverter.PointConverter() {
+      public Point2D toViewPoint(Coordinate modelCoordinate) {
+        return new Point2D.Double((modelCoordinate.x-c.x), 
(modelCoordinate.y-c.y));
+      }
+      public double getScale() { return 1.0;}
+      public Envelope getEnvelopeInModelCoordinates() {
+        return new Envelope(0.0, 20, 0.0, 20);
+      }
+    });
+    return java2DConverter.toShape(geometry);
+  }
+
+  /** Create an icon from the Geometry.*/
+  private ImageIcon createIcon(Geometry geometry) throws 
NoninvertibleTransformException {
+    final Envelope env = geometry.getEnvelopeInternal();
+    final double max = Math.max(env.getWidth(), env.getHeight());
+    Java2DConverter java2DConverter = new Java2DConverter(new 
Java2DConverter.PointConverter() {
+      public Point2D toViewPoint(Coordinate modelCoordinate) {
+        return new Point2D.Double((modelCoordinate.x-env.getMinX()) * 
getScale(), 20.0 - (modelCoordinate.y-env.getMinY()) * getScale());
+      }
+      public double getScale() { return 20.0/max;}
+      public Envelope getEnvelopeInModelCoordinates() {
+        return new Envelope(0.0, 20, 0.0, 20);
+      }
+    });
+    Shape shape = java2DConverter.toShape(geometry);
+    //Rectangle r = shape.getBounds();
+    BufferedImage image = new BufferedImage(22, 22, 
BufferedImage.TYPE_INT_ARGB);
+    Graphics2D g = image.createGraphics();
+    g.draw(shape);
+    // move the shape in the region of the image
+    //g.translate(10, 10);
+    g.setPaint(Color.red);
+    g.draw(shape);
+    g.dispose();
+    return new ImageIcon(image);
+  }
+
+}

Modified: 
plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/BlockCellRenderer.java
===================================================================
--- 
plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/BlockCellRenderer.java
     2018-01-05 13:34:20 UTC (rev 5665)
+++ 
plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/BlockCellRenderer.java
     2018-01-07 21:02:59 UTC (rev 5666)
@@ -10,6 +10,10 @@
 import javax.swing.JLabel;
 import javax.swing.JList;
 
+/**
+ * @deprecated now included and inlined in {@link BlockPanel}.
+ */
+@Deprecated
 public class BlockCellRenderer extends DefaultListCellRenderer {
     private static final long serialVersionUID = 1L;
     private List<String> tooltips;

Modified: 
plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/BlockPanel.java
===================================================================
--- 
plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/BlockPanel.java
    2018-01-05 13:34:20 UTC (rev 5665)
+++ 
plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/BlockPanel.java
    2018-01-07 21:02:59 UTC (rev 5666)
@@ -1,38 +1,17 @@
 package org.openjump.advancedtools.block;
 
-import java.awt.BorderLayout;
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.Graphics2D;
-import java.awt.GridBagLayout;
-import java.awt.GridLayout;
-import java.awt.Shape;
-import java.awt.image.BufferedImage;
+import java.awt.*;
 import java.io.File;
-import java.util.ArrayList;
-import java.util.HashMap;
+import java.util.*;
 import java.util.List;
-import java.util.Vector;
 
-import javax.swing.BorderFactory;
-import javax.swing.DefaultComboBoxModel;
-import javax.swing.Icon;
-import javax.swing.ImageIcon;
-import javax.swing.JButton;
-import javax.swing.JComboBox;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JSpinner;
-import javax.swing.SpinnerModel;
-import javax.swing.SpinnerNumberModel;
+import javax.swing.*;
 import javax.swing.border.TitledBorder;
 
+import com.vividsolutions.jts.geom.Geometry;
 import org.openjump.advancedtools.language.I18NPlug;
-import org.saig.core.gui.swing.sldeditor.util.FormUtils;
 
-import com.vividsolutions.jts.geom.Geometry;
 import com.vividsolutions.jump.I18N;
-import com.vividsolutions.jump.workbench.JUMPWorkbench;
 import com.vividsolutions.jump.workbench.WorkbenchContext;
 import com.vividsolutions.jump.workbench.plugin.EnableCheck;
 import com.vividsolutions.jump.workbench.plugin.PlugIn;
@@ -39,63 +18,45 @@
 import com.vividsolutions.jump.workbench.plugin.PlugInContext;
 import com.vividsolutions.jump.workbench.ui.WorkbenchToolBar;
 
+import static java.awt.GridBagConstraints.WEST;
+
 public class BlockPanel extends JPanel {
 
-    static WorkbenchContext context = JUMPWorkbench.getInstance().getFrame()
-            .getContext();
     private static final long serialVersionUID = 1L;
     public static final String blockFolder = "VertexImages";
     public static final String NAME = "Insert symbol as block";
-    @SuppressWarnings("rawtypes")
-    public static JComboBox chooseBox;
 
-    public static DefaultComboBoxModel model = new DefaultComboBoxModel();
+    public static JComboBox<BlockCell> chooseBox = new JComboBox<>();
 
-    public static JPanel block_panel = new JPanel(new GridLayout(0, 1));
-    public static JPanel option_panel = new JPanel(new GridLayout(0, 1));
-    public static JPanel preview_panel = new JPanel(new GridLayout(0, 1));
-    public static JPanel mainPanel = new JPanel(new GridLayout(0, 1));
-    public static JLabel block_panel_jlabel;
-    public static JLabel option_panel_jlabel1;
-    public static JLabel option_panel_jlabel2;
-
-    // public static JPanel previewPanel = new JPanel();
-    public static JButton jButton_Help = new JButton();
-    private static TitledBorder titledBorder;
-    @SuppressWarnings("rawtypes")
-    public static List blocks;
-    public static HashMap<Object, Shape> shapes;
-
     public static String circle = I18N
             .get("deejump.ui.style.RenderingStylePanel.circle");
-
     public static String triangle = I18N
             .get("deejump.ui.style.RenderingStylePanel.triangle");
     public static String square = I18N
             .get("deejump.ui.style.RenderingStylePanel.square");
-    public static String hexagon = "hexagon";
     public static String cross = I18N
             .get("deejump.ui.style.RenderingStylePanel.cross");
     public static String star = I18N
             .get("deejump.ui.style.RenderingStylePanel.star");
-    public static SpinnerModel rotationModel = new SpinnerNumberModel(0, // 
initial
+
+    private SpinnerModel rotationModel = new SpinnerNumberModel(0, // initial
             // value
-            0, // min
+            0,   // min
             359, // max
             1);
-    public static SpinnerModel dimensionModel = new SpinnerNumberModel(100, // 
initial
+
+    private SpinnerModel dimensionModel = new SpinnerNumberModel(100, // 
initial
             // value
             10, // min
-            400, // max
+            1000, // max
             10);
+
     public static JSpinner rotationSpinner = new JSpinner();
 
     public static JSpinner dimensionSpinner = new JSpinner();
 
     private static WorkbenchToolBar toolBar = new WorkbenchToolBar(null) {
-        /**
-         *
-         */
+
         private static final long serialVersionUID = 1L;
 
         @Override
@@ -108,123 +69,128 @@
 
     @SuppressWarnings({})
     public JPanel panel_blocks(PlugInContext context) {
+        JPanel mainPanel = new JPanel(new GridBagLayout());
 
-        block_panel = new JPanel(new GridBagLayout());
-        block_panel_jlabel = new JLabel(
-                
I18NPlug.getI18N("org.openjump.core.ui.plugins.block.dialog.select-block"));
-        block_panel_jlabel
-                .setToolTipText(I18NPlug
-                        
.getI18N("org.openjump.core.ui.plugins.block.dialog.dialog.select-block-message"));
+        initToolBar(context.getWorkbenchContext());
+        JPanel blockChooserPanel = getBlockChooserPanel(context);
 
+        dimensionSpinner = new JSpinner(dimensionModel);
+        JLabel labelDimension = new JLabel(
+                
I18NPlug.getI18N("org.openjump.core.ui.plugins.block.dialog-dimension"));
+        labelDimension.setToolTipText(gedDimensionTooltip());
+
         rotationSpinner = new JSpinner(rotationModel);
-        option_panel_jlabel1 = new JLabel(
+        JLabel labelRotation = new JLabel(
                 
I18NPlug.getI18N("org.openjump.core.ui.plugins.block.dialog-rotation"));
-        option_panel_jlabel1
-                .setToolTipText(I18NPlug
-                        
.getI18N("org.openjump.core.ui.plugins.annotation.dialog.font-rotation-message"));
+        labelRotation.setToolTipText(
+                
I18NPlug.getI18N("org.openjump.core.ui.plugins.annotation.dialog.font-rotation-message"));
 
-        dimensionSpinner = new JSpinner(dimensionModel);
-        option_panel_jlabel2 = new JLabel(
-                
I18NPlug.getI18N("org.openjump.core.ui.plugins.block.dialog-dimension"));
-        option_panel_jlabel2.setToolTipText(gedtDescription());
 
-        FormUtils.addRowInGBL(block_panel, 1, 0, null, option_panel_jlabel2,
-                dimensionSpinner, option_panel_jlabel1, rotationSpinner);
-
-        mainPanel = new JPanel(new GridBagLayout());
-        titledBorder = new TitledBorder(BorderFactory.createEtchedBorder(
+        TitledBorder titledBorder = new 
TitledBorder(BorderFactory.createEtchedBorder(
                 Color.white, new Color(148, 145, 140)),
                 I18NPlug.getI18N("org.openjump.core.ui.plugins.block"));
         mainPanel.setBorder(titledBorder);
-        initToolBar(context.getWorkbenchContext());
-        FormUtils.addRowInGBL(mainPanel, 1, 0, toolBar);
-        FormUtils.addRowInGBL(mainPanel, 2, 0, block_panel);
 
+        GridBagConstraints c = new GridBagConstraints();
+        c.anchor = WEST;
+        c.insets = new Insets(2,4,2,4);
+
+        c.gridwidth = 4;
+        //FormUtils.addRowInGBL(mainPanel, 0, 0, toolBar);
+        mainPanel.add(toolBar, c);
+
+        c.gridy = 1;
+        mainPanel.add(blockChooserPanel, c);
+
+        c.gridx = 0; c.gridy = 2; c.gridwidth = 1;
+        mainPanel.add(labelDimension, c);
+        c.gridx = 1;
+        mainPanel.add(dimensionSpinner, c);
+        c.gridx = 2;
+        mainPanel.add(labelRotation, c);
+        c.gridx = 3;
+        mainPanel.add(rotationSpinner, c);
+
         return mainPanel;
     }
 
-    public static List<String> list;
 
-    @SuppressWarnings({ "unchecked", "rawtypes" })
-    public static  JPanel chooseBlockPanel(PlugInContext context) {
+    private JPanel getBlockChooserPanel(PlugInContext context) {
 
-        chooseBox = new JComboBox(new Vector(listOfBlockFiles(context)));
-
-        Dimension d = new Dimension(125, chooseBox.getPreferredSize().height);
+        Dimension d = new Dimension(125, 
/*chooseBox.getPreferredSize().height*/ 26);
         chooseBox.setPreferredSize(d);
 
-  /*      BlockCellRenderer renderer = new BlockCellRenderer();
-        chooseBox.setRenderer(renderer);
-        list = listOfBlockFiles(context);
-        HashMap<Object, Icon> icons = ListOfBlocksIcons();
-        renderer.setTooltips(list);
-        renderer.setIcons(icons);*/
+        chooseBox.setRenderer(new DefaultListCellRenderer() {
+            @Override
+            public Component getListCellRendererComponent(
+                    JList list, Object value, int index,
+                    boolean isSelected, boolean cellHasFocus) {
 
-        model = (DefaultComboBoxModel) chooseBox.getModel();
-        JPanel test_block_panel = new JPanel(new GridBagLayout());
+                JLabel label = (JLabel) 
super.getListCellRendererComponent(list, value,
+                        index, isSelected, cellHasFocus);
+                if (/*-1 < index && null != value &&*/ value instanceof 
BlockCell) {
+                    label.setIcon(((BlockCell)value).getIcon());
+                }
+                return label;
+            }
+        });
+        initComboBox(context);
 
-        test_block_panel
-                .setToolTipText(I18NPlug
+        JPanel blockChooserPanel = new JPanel();
+        JLabel chooseBlockLabel = new JLabel(
+                
I18NPlug.getI18N("org.openjump.core.ui.plugins.block.dialog.select-block"));
+        blockChooserPanel.setToolTipText(I18NPlug
                         
.getI18N("org.openjump.core.ui.plugins.block.dialog.dialog.select-block-message"));
-        test_block_panel.add(chooseBox);
+        blockChooserPanel.add(chooseBlockLabel);
+        blockChooserPanel.add(chooseBox);
 
-        return test_block_panel;
+        return blockChooserPanel;
     }
 
     private void initToolBar(WorkbenchContext context) {
-        DrawBlockPlugIn draw = new DrawBlockPlugIn();
-        SaveBlockPlugIn save = new SaveBlockPlugIn();
+        DrawBlockPlugIn draw = new DrawBlockPlugIn(this);
+        // SaveBlockPlugIn must contain a reference to this BlockPanel
+        SaveBlockPlugIn save = new SaveBlockPlugIn(this);
         // ShowHelpPlugIn help = new ShowHelpPlugIn();
-        DrawOrientedBlockPlugIn drag = new DrawOrientedBlockPlugIn();
+        DrawOrientedBlockPlugIn drag = new DrawOrientedBlockPlugIn(this);
 
         toolBar.addPlugIn(draw.getIcon(), draw, null, context);
         toolBar.addPlugIn(drag.getIcon(), drag, null, context);
         toolBar.addPlugIn(save.getIcon(), save, null, context);
-        toolBar.addSeparator();
-        toolBar.add(chooseBlockPanel(context.createPlugInContext()),
-                BorderLayout.EAST);
+    }
 
-        // ShowBlockPlugIn showBlockPlugIn = new ShowBlockPlugIn();
-        // toolBar.addPlugIn(save.getIcon(), showBlockPlugIn, null, context);
-        // toolBar.addPlugIn(help.getIcon(), help, null, context);
+    void initComboBox(PlugInContext context) {
+        chooseBox.removeAllItems();
+        for (BlockCell block : getAllBlockCells(context)) {
+            chooseBox.addItem(block);
+        }
+        chooseBox.revalidate();
     }
 
-    @SuppressWarnings("unchecked")
-    public static  List<String> listOfBlockFiles(PlugInContext context) {
+    public Geometry getSelection() {
+        return chooseBox.getSelectedItem() == null ? null :
+                
(Geometry)((BlockCell)chooseBox.getSelectedItem()).getGeometry().clone();
+    }
+
+    private List<BlockCell> getAllBlockCells(PlugInContext context) {
         File pluginDir = context.getWorkbenchContext().getWorkbench()
                 .getPlugInManager().getPlugInDirectory();
-        String wd = pluginDir.getAbsolutePath();
-        blocks = new ArrayList<String>();
-        blocks.add(square);
-        blocks.add(circle);
-        blocks.add(triangle);
-        blocks.add(cross);
-        blocks.add(star);
+        File folder = new File(pluginDir,blockFolder);
+        List<BlockCell> blocks = new ArrayList<>();
+        blocks.add(BlockCell.SQUARE);
+        blocks.add(BlockCell.CIRCLE);
+        blocks.add(BlockCell.TRIANGLE);
+        blocks.add(BlockCell.CROSS);
+        blocks.add(BlockCell.STAR);
         try {
-            String block_folder = wd + File.separator + blockFolder;
-            File directory = new File(block_folder);
-            // get all the files from a directory
-            File[] fList = directory.listFiles();
-            String fileName = null;
-            for (File file : fList) {
-                if (file.isFile()) {
-                    String ext = null;
-                    String s = file.getName();
-                    int i = s.lastIndexOf('.');
-                    if (i > 0 && i < s.length() - 1) {
-                        ext = s.substring(i + 1).toUpperCase();
+            File[] fList = folder.listFiles();
+            if (fList != null) {
+                for (File file : fList) {
+                    if (file.isFile() && 
file.getName().toUpperCase().endsWith(".WKT")) {
+                        blocks.add(new BlockCell(file));
                     }
-                    if (ext.equals("WKT"))
-                        fileName = file.getName();
-                    int pos = fileName.lastIndexOf(".");
-                    if (pos > 0) {
-                        fileName = fileName.substring(0, pos);
-                        fileName.substring(pos, fileName.length());
-                    }
-                    blocks.add(fileName);
                 }
             }
-
         } catch (Exception ex) {
             ex.printStackTrace();
         }
@@ -231,108 +197,17 @@
         return blocks;
     }
 
-    private static HashMap<Object, Icon> icons = new HashMap<Object, Icon>();
 
-    public static HashMap<Object, Icon> ListOfBlocksIcons() {
-        File pluginDir = context.getWorkbench().getPlugInManager()
-                .getPlugInDirectory();
-        String wd = pluginDir.getAbsolutePath();
-        icons = new HashMap<Object, Icon>();
+    private String gedDimensionTooltip() {
 
-        try {
-            Geometry geom1 = BlockUtils.square();
-            Shape shape1 = context.getLayerViewPanel().getJava2DConverter()
-                    .toShape(geom1);
-            icons.put("shapes", BlockUtils.createIcon(shape1));
+        String dimension   = 
I18NPlug.getI18N("org.openjump.core.ui.plugins.block.define-dimension");
+        String description = 
I18NPlug.getI18N("org.openjump.core.ui.plugins.block.define-dimension-description");
+        String style       = "width: 200px; text-justification: justify;";
 
-            Geometry geom2 = BlockUtils.circle();
-            Shape shape2 = context.getLayerViewPanel().getJava2DConverter()
-                    .toShape(geom2);
-            icons.put("shapes", BlockUtils.createIcon(shape2));
-
-            Geometry geom3 = BlockUtils.triangle();
-            Shape shape3 = context.getLayerViewPanel().getJava2DConverter()
-                    .toShape(geom3);
-            icons.put("shapes", BlockUtils.createIcon(shape3));
-
-            Geometry geom4 = BlockUtils.cross();
-            Shape shape4 = context.getLayerViewPanel().getJava2DConverter()
-                    .toShape(geom4);
-            icons.put("shapes", BlockUtils.createIcon(shape4));
-
-            Geometry geom5 = BlockUtils.star();
-            Shape shape5 = context.getLayerViewPanel().getJava2DConverter()
-                    .toShape(geom5);
-            icons.put("shapes", BlockUtils.createIcon(shape5));
-            String block_folder = wd + File.separator + blockFolder;
-            File directory = new File(block_folder);
-            // get all the files from a directory
-            File[] fList = directory.listFiles();
-            Geometry geom = null;
-            for (File file : fList) {
-
-                if (file.isFile()) {
-                    String ext = null;
-                    String s = file.getName();
-                    int i = s.lastIndexOf('.');
-                    if (i > 0 && i < s.length() - 1) {
-                        ext = s.substring(i + 1).toUpperCase();
-                    }
-                    if (ext.equals("WKT")) {
-
-                        String blockName = (String) BlockPanel.chooseBox
-                                .getSelectedItem() + ".wkt";
-                        /*
-                         * geom2 = BlockUtils.readGeomFromWKT(
-                         * context.getWorkbenchContext(), blockName,
-                         * BlockPanel.blockFolder);
-                         */
-
-                        geom = BlockUtils.readGeomFromWKT(blockName,
-                                BlockPanel.blockFolder);
-
-                    }
-                    Shape selectedShape = context.getLayerViewPanel()
-                            .getJava2DConverter().toShape(geom);
-                    icons.put("shapes", BlockUtils.createIcon(selectedShape));
-                }
-
-            }
-        } catch (Exception ex) {
-            ex.printStackTrace();
-        }
-
-        return icons;
+        return String.format(
+                "<HTML><BODY><DIV 
style=\"%s\"><b>%s</b><br>%s</DIV></BODY></HTML>",
+                style, dimension, description
+        );
     }
 
-    public String gedtDescription() {
-
-        String tooltip = "";
-        tooltip = "<HTML><BODY>";
-        tooltip += "<DIV style=\"width: 200px; text-justification: 
justify;\">";
-        tooltip += "<b>"
-                + I18NPlug
-                .getI18N("org.openjump.core.ui.plugins.block.define-dimension")
-                + "</b>" + "<br>";
-        tooltip += I18NPlug
-                
.getI18N("org.openjump.core.ui.plugins.block.define-dimension-description")
-                + "<br>";
-        tooltip += "</DIV></BODY></HTML>";
-        return tooltip;
-    }
-
-    public Icon makeIcon(Shape s) {
-
-        BufferedImage image = new BufferedImage(20, 20,
-                BufferedImage.TYPE_BYTE_BINARY);
-        Graphics2D gr = image.createGraphics();
-        // move the shape in the region of the image
-        gr.setColor(Color.red);
-        gr.setBackground(Color.white);
-        gr.draw(s);
-        gr.dispose();
-        ImageIcon icon = new ImageIcon(image);
-        return icon;
-    }
-
 }
\ No newline at end of file

Modified: 
plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/BlockUtils.java
===================================================================
--- 
plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/BlockUtils.java
    2018-01-05 13:34:20 UTC (rev 5665)
+++ 
plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/BlockUtils.java
    2018-01-07 21:02:59 UTC (rev 5666)
@@ -26,6 +26,10 @@
 import com.vividsolutions.jump.workbench.WorkbenchContext;
 import com.vividsolutions.jump.workbench.plugin.PlugInManager;
 
+/**
+ * @deprecated entirely replaced by the new {@link BlockCell} class.
+ */
+@Deprecated
 public class BlockUtils {
 
     static WorkbenchContext context = JUMPWorkbench.getInstance().getFrame()
@@ -34,6 +38,7 @@
     // Reads Geometry form a wkt file. Since the files are from VertexFolder 
and
     // have a difference
     // in wkt syntax, the text before the wkt geometry specification is 
excluded
+    @Deprecated
     public static Geometry readGeomFromWKT(String filename, String folder)
             throws IOException, com.vividsolutions.jts.io.ParseException {
         PlugInManager manager = context.getWorkbench().getPlugInManager();
@@ -75,6 +80,7 @@
      */
 
     // Get the geometry
+    @Deprecated
     public static Geometry getGeometry() throws IOException, ParseException {
         Geometry geom2 = null;
         if (BlockPanel.chooseBox.getSelectedItem().toString()
@@ -103,6 +109,7 @@
     }
 
     // Get the geometry
+    @Deprecated
     public static Shape getShape() throws IOException, ParseException,
             NoninvertibleTransformException {
         Geometry geom2 = null;
@@ -158,6 +165,7 @@
     /*
      * Use Scanner to read the content of a file
      */
+    @Deprecated
     public static String readFile(String pathname) throws IOException {
 
         File file = new File(pathname);
@@ -178,12 +186,13 @@
     /*
      * List of embedded geometries
      */
-
+    @Deprecated
     public static Geometry circle() {
         Circle circle = new Circle(new Coordinate(0, 0), 8);
         return circle.getPoly();
     }
 
+  @Deprecated
     public static Geometry triangle() {
         Coordinate[] coords = new Coordinate[] { new Coordinate(0, 0),
                 new Coordinate(16, 0), new Coordinate(8, 13.85),
@@ -193,6 +202,7 @@
         return geo;
     }
 
+  @Deprecated
     public static Geometry square() {
         Coordinate[] coords = new Coordinate[] { new Coordinate(0, 0),
                 new Coordinate(0, 16), new Coordinate(16, 16),
@@ -202,6 +212,7 @@
         return geo;
     }
 
+  @Deprecated
     public static Geometry cross() {
         Coordinate[] coords = new Coordinate[] { new Coordinate(5, 0),
                 new Coordinate(10, 0), new Coordinate(10, 5),
@@ -216,6 +227,7 @@
         return geo;
     }
 
+  @Deprecated
     public static Geometry star() {
         Coordinate[] coords = new Coordinate[] { new Coordinate(4, 6),
                 new Coordinate(1, 6), new Coordinate(3, 4),
@@ -230,6 +242,7 @@
         return geo;
     }
 
+  @Deprecated
     public static Geometry star_old() {
         Coordinate[] coords = new Coordinate[] { new Coordinate(3.82, 0.0),
                 new Coordinate(5, 6.88), new Coordinate(0.0, 11.76),
@@ -243,6 +256,7 @@
         return geo;
     }
 
+  @Deprecated
     public static Geometry star_test() {
 
         int s = 10;
@@ -304,6 +318,7 @@
      * + ".wkt"; geom2 = readGeomFromWKT(context, blockName,
      * BlockPanel.blockFolder); } return geom2; }
      */
+    @Deprecated
     public static ImageIcon createIcon(Shape shape) throws IOException,
             ParseException, NoninvertibleTransformException {
 
@@ -324,6 +339,7 @@
         return icon;
     }
 
+  @Deprecated
     public ImageIcon creatIconFromShape(Shape s) {
 
         Rectangle r = s.getBounds();
@@ -342,6 +358,7 @@
         return icon;
     }
 
+  @Deprecated
     public static Shape generateShapeFromText(Font font, String string) {
         BufferedImage img = new BufferedImage(24, 24,
                 BufferedImage.TYPE_INT_ARGB);

Modified: 
plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/DrawBlockPlugIn.java
===================================================================
--- 
plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/DrawBlockPlugIn.java
       2018-01-05 13:34:20 UTC (rev 5665)
+++ 
plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/DrawBlockPlugIn.java
       2018-01-07 21:02:59 UTC (rev 5666)
@@ -1,6 +1,6 @@
 package org.openjump.advancedtools.block;
 
-import javax.swing.ImageIcon;
+import javax.swing.*;
 
 import org.openjump.advancedtools.icon.IconLoader;
 import org.openjump.advancedtools.language.I18NPlug;
@@ -25,6 +25,13 @@
     public static final String NAME2 = I18NPlug
             
.getI18N("org.openjump.core.ui.plugins.block.DrawblockTool.description");
 
+    BlockPanel blockPanel;
+
+    public DrawBlockPlugIn(BlockPanel blockPanel) {
+        super();
+        this.blockPanel = blockPanel;
+    }
+
     @Override
     public boolean execute(PlugInContext context) throws Exception {
         reportNothingToUndoYet(context);
@@ -40,7 +47,7 @@
             try {
                 CursorTool polyTool = DrawBlockTool
                         .create((LayerNamePanelProxy) context
-                                .getActiveInternalFrame());
+                                .getActiveInternalFrame(), blockPanel);
                 context.getLayerViewPanel().setCurrentCursorTool(polyTool);
             } catch (Exception ex) {
                 WorkbenchUtils.Logger(this.getClass(), ex);

Modified: 
plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/DrawBlockTool.java
===================================================================
--- 
plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/DrawBlockTool.java
 2018-01-05 13:34:20 UTC (rev 5665)
+++ 
plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/DrawBlockTool.java
 2018-01-07 21:02:59 UTC (rev 5666)
@@ -34,21 +34,23 @@
     private ImageIcon ICON = org.openjump.advancedtools.icon.IconLoader
             .icon("textblock/block_ins.png");
 
-    public DrawBlockTool(FeatureDrawingUtil featureDrawingUtil) {
+    final BlockPanel blockPanel;
+
+    public DrawBlockTool(FeatureDrawingUtil featureDrawingUtil, BlockPanel 
blockPanel) {
         super(1);
         this.featureDrawingUtil = featureDrawingUtil;
         setColor(Color.blue);
         setStroke(new BasicStroke(1.5F));
-
         allowSnapping();
+        this.blockPanel = blockPanel;
     }
 
-    public static CursorTool create(LayerNamePanelProxy layerNamePanelProxy) {
+    public static CursorTool create(LayerNamePanelProxy layerNamePanelProxy, 
BlockPanel blockPanel) {
         FeatureDrawingUtil featureDrawingUtil = new FeatureDrawingUtil(
                 layerNamePanelProxy);
 
         return featureDrawingUtil.prepare(
-                new DrawBlockTool(featureDrawingUtil), true);
+                new DrawBlockTool(featureDrawingUtil, blockPanel), true);
     }
 
     public void initialize(PlugInContext context) throws Exception {
@@ -69,10 +71,11 @@
         // Build the geometry at the specific displacement, dimension and
         // rotation
         // Geometry geom2 = BlockUtils.getGeometry(context);
-        Geometry geom2 = BlockUtils.getGeometry();
+        //Geometry geom2 = BlockUtils.getGeometry();
+        Geometry geom2 = blockPanel.getSelection();
 
         // Get the centroid coordinates of the geometry
-        Coordinate coord = geom2.getEnvelope().getCentroid().getCoordinate();
+        Coordinate coord = geom2.getCentroid().getCoordinate();
 
         // Calculate the displacement of the geometry
         Coordinate displacement = CoordUtil.subtract(cursorPt, coord);
@@ -127,14 +130,8 @@
      */
     @Override
     protected Shape getShape() {
-
         this.setColor(Color.RED.brighter());
-        try {
-            this.calculateShape(this.modelDestination, this.getPanel());
-        } catch (IOException | ParseException e) {
-            WorkbenchUtils.Logger(this.getClass(), e);
-            e.printStackTrace();
-        }
+        this.calculateShape(this.modelDestination, this.getPanel());
         return this.selectedFeaturesShape;
     }
 
@@ -149,17 +146,15 @@
      * @throws ParseException
      * @throws IOException
      */
-    private void calculateShape(Coordinate middlePoint, LayerViewPanel panel)
-            throws IOException, ParseException {
+    private void calculateShape(Coordinate middlePoint, LayerViewPanel panel) {
         getWorkbench().getContext();
         // Get the click coordinates
         Coordinate cursorPt = this.modelDestination;
-        Geometry geom2 = BlockUtils.getGeometry();
-        // Geometry geom2 = BlockUtils.getGeometry(context);
+        // get the geometry of the block
+        Geometry geom2 = blockPanel.getSelection();
+        // Get the centroid of the geometry
+        Coordinate coord = geom2.getCentroid().getCoordinate();
 
-        // Get the centroid coordinates of the geometry
-        Coordinate coord = geom2.getEnvelope().getCentroid().getCoordinate();
-
         // Calculate the displacement of the geometry
         Coordinate displacement = CoordUtil.subtract(cursorPt, coord);
         Integer rotation = (Integer) BlockPanel.rotationSpinner.getValue();
@@ -169,8 +164,7 @@
         GeometryUtils.centerGeometry(geom2, displacement);
 
         try {
-            this.selectedFeaturesShape = panel.getJava2DConverter().toShape(
-                    geom2);
+            this.selectedFeaturesShape = 
panel.getJava2DConverter().toShape(geom2);
         } catch (NoninvertibleTransformException e) {
             System.out.println("DrawCircleWithGivenRadiusTool:Exception " + e);
         }

Modified: 
plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/DrawOrientedBlockPlugIn.java
===================================================================
--- 
plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/DrawOrientedBlockPlugIn.java
       2018-01-05 13:34:20 UTC (rev 5665)
+++ 
plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/DrawOrientedBlockPlugIn.java
       2018-01-07 21:02:59 UTC (rev 5666)
@@ -25,6 +25,13 @@
     public static final String NAME2 = I18NPlug
             
.getI18N("org.openjump.core.ui.plugins.block.DrawOrientedBlockTool.description");
 
+    BlockPanel blockPanel;
+
+    public DrawOrientedBlockPlugIn(BlockPanel blockPanel) {
+        super();
+        this.blockPanel = blockPanel;
+    }
+
     @Override
     public boolean execute(PlugInContext context) throws Exception {
         reportNothingToUndoYet(context);
@@ -40,7 +47,7 @@
             try {
                 CursorTool polyTool = DrawOrientedBlockTool
                         .create((LayerNamePanelProxy) context
-                                .getActiveInternalFrame());
+                                .getActiveInternalFrame(), blockPanel);
                 context.getLayerViewPanel().setCurrentCursorTool(polyTool);
             } catch (Exception ex) {
                 WorkbenchUtils.Logger(this.getClass(), ex);

Modified: 
plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/DrawOrientedBlockTool.java
===================================================================
--- 
plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/DrawOrientedBlockTool.java
 2018-01-05 13:34:20 UTC (rev 5665)
+++ 
plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/DrawOrientedBlockTool.java
 2018-01-07 21:02:59 UTC (rev 5666)
@@ -33,7 +33,6 @@
 import com.vividsolutions.jump.workbench.ui.cursortool.CursorTool;
 import 
com.vividsolutions.jump.workbench.ui.cursortool.editing.FeatureDrawingUtil;
 
-//import org.openjump.core.ui.utils.GeometryUtils;
 
 public class DrawOrientedBlockTool extends ConstrainedNClickTool {
     private FeatureDrawingUtil featureDrawingUtil;
@@ -46,12 +45,15 @@
     private ImageIcon ICON = org.openjump.advancedtools.icon.IconLoader
             .icon("textblock/block_drag.png");
 
-    public DrawOrientedBlockTool(FeatureDrawingUtil featureDrawingUtil) {
+    final BlockPanel blockPanel;
+
+    public DrawOrientedBlockTool(FeatureDrawingUtil featureDrawingUtil, 
BlockPanel blockPanel) {
         super(2);
         this.featureDrawingUtil = featureDrawingUtil;
         setColor(Color.blue);
         setStroke(new BasicStroke(1.5F));
         allowSnapping();
+        this.blockPanel = blockPanel;
     }
 
     double angle;
@@ -74,12 +76,12 @@
         return (int) this.angle;
     }
 
-    public static CursorTool create(LayerNamePanelProxy layerNamePanelProxy) {
+    public static CursorTool create(LayerNamePanelProxy layerNamePanelProxy, 
BlockPanel blockPanel) {
         FeatureDrawingUtil featureDrawingUtil = new FeatureDrawingUtil(
                 layerNamePanelProxy);
 
         return featureDrawingUtil.prepare(new DrawOrientedBlockTool(
-                featureDrawingUtil), true);
+                featureDrawingUtil, blockPanel), true);
     }
 
     public void initialize(PlugInContext context) throws Exception {
@@ -95,6 +97,9 @@
     public void gestureFinished() throws Exception {
         getWorkbench().getContext();
 
+        // If the mouse is released before the scond click, do nothing
+        if (getCoordinates().size()==0) return;
+
         // Build the geometry at the specific displacement, dimension and
         // rotation
 
@@ -106,10 +111,11 @@
             angle_1 = azimuth(cursorPt, tentativeCoordinate);
         }
 
-        Geometry geom2 = BlockUtils.getGeometry();
+        //Geometry geom2 = BlockUtils.getGeometry();
+        Geometry geom2 = blockPanel.getSelection();
 
         // Get the centroid coordinates of the geometry
-        Coordinate coord = geom2.getEnvelope().getCentroid().getCoordinate();
+        Coordinate coord = geom2.getCentroid().getCoordinate();
         // Calculate the dsplacement of the geometry
         Coordinate displacement = CoordUtil.subtract(cursorPt, coord);
 
@@ -161,7 +167,7 @@
                             Azimuth
                                     + ": "
                                     + df2.format(azimuth(cursorPt,
-                                            tentativeCoordinate)) + "\xB0");
+                                            tentativeCoordinate)) + "�");
         }
     }
 
@@ -173,13 +179,11 @@
      * calculates a geometry around the mouse pointer and converts it to a java
      * shape
      * 
-     * @param middlePoint
-     *            coordinates of the circle
+     * @param panel
      * @throws ParseException
      * @throws IOException
      */
-    private void calculateShape(LayerViewPanel panel) throws IOException,
-            ParseException, NoninvertibleTransformException {
+    private void calculateShape(LayerViewPanel panel) {
         Coordinate cursorPt = (Coordinate) getCoordinates().get(0);
         double angle_1;
         if (getCoordinates().size() == 1) {
@@ -189,11 +193,10 @@
         }
         getWorkbench().getContext();
 
-        Geometry geom2 = BlockUtils.getGeometry();
-        // Geometry geom2 = BlockUtils.getGeometry(context);
+        Geometry geom2 = blockPanel.getSelection();
 
-        // Get the centroid coordinates of the geometry
-        Coordinate coord = geom2.getEnvelope().getCentroid().getCoordinate();
+        // Get the centroid of the geometry
+        Coordinate coord = geom2.getCentroid().getCoordinate();
 
         // Calculate the displacement of the geometry
         Coordinate displacement = CoordUtil.subtract(cursorPt, coord);
@@ -218,10 +221,11 @@
         // Get the click coordinates
         Coordinate cursorPt = this.modelDestination;
         // Geometry geom2 = BlockUtils.getGeometry(context);
-        Geometry geom2 = BlockUtils.getGeometry();
+        //Geometry geom2 = BlockUtils.getGeometry();
+        Geometry geom2 = blockPanel.getSelection();
 
         // Get the centroid coordinates of the geometry
-        Coordinate coord = geom2.getEnvelope().getCentroid().getCoordinate();
+        Coordinate coord = geom2.getCentroid().getCoordinate();
 
         // Calculate the displacement of the geometry
         Coordinate displacement = CoordUtil.subtract(cursorPt, coord);
@@ -231,8 +235,7 @@
         GeometryUtils.centerGeometry(geom2, displacement);
 
         try {
-            this.selectedFeaturesShape = panel.getJava2DConverter().toShape(
-                    geom2);
+            this.selectedFeaturesShape = 
panel.getJava2DConverter().toShape(geom2);
         } catch (NoninvertibleTransformException e) {
             System.out.println("DrawCircleWithGivenRadiusTool:Exception " + e);
         }
@@ -257,12 +260,10 @@
             } else if (getCoordinates().size() == 1) {
 
                 Coordinate a = (Coordinate) coordinates.get(0);
-                String Azimuth = df2.format(azimuth(a, this.modelDestination))
-                        + "\xB0";
-                Font f1 = new Font("Arial Black", Font.ITALIC, 20);
-                Shape text = BlockUtils.generateShapeFromText(f1, Azimuth);
+                //String Azimuth = df2.format(azimuth(a, 
this.modelDestination)) + "�";
+                //Font f1 = new Font("Arial Black", Font.ITALIC, 20);
+                Shape shape = BlockCell.getShape(blockPanel.getSelection());
 
-                ;
                 this.calculateShape(this.getPanel());
                 // this.calculateShape_0(a, this.getPanel());
                 Point2D firstPoint = getPanel().getViewport().toViewPoint(a);
@@ -285,19 +286,19 @@
                 this.calculateShape(this.getPanel());
                 AffineTransform at = new AffineTransform();
                 at.translate(thirdPoint.getX(), thirdPoint.getY());
-                at.createTransformedShape(text);
+                at.createTransformedShape(shape);
                 if (this.wasControlPressed()) {
-                    path.append(at.createTransformedShape(text), false);
+                    path.append(at.createTransformedShape(shape), false);
                 }
                 path.append(this.selectedFeaturesShape, false);
             } else {
 
                 Coordinate a = (Coordinate) coordinates.get(0);
-                String Azimuth = df2.format(azimuth(a, tentativeCoordinate))
-                        + "\xB0";
-                Font f1 = new Font("Arial Black", Font.ITALIC, 20);
-                Shape text = BlockUtils.generateShapeFromText(f1, Azimuth);
+                //String Azimuth = df2.format(azimuth(a, tentativeCoordinate)) 
+ "�";
+                //Font f1 = new Font("Arial Black", Font.ITALIC, 20);
 
+                Shape text = BlockCell.getShape(blockPanel.getSelection());
+
                 Point2D firstPoint = getPanel().getViewport().toViewPoint(a);
                 path.moveTo((float) firstPoint.getX(),
                         (float) firstPoint.getY());
@@ -338,7 +339,8 @@
     /**
      * Computes the angle facing North betwee 2 points
      *
-     * @param coordinates
+     * @param startPt
+     * @param endPt
      * @return the angle in degrees
      */
     public static double azimuth(Coordinate startPt, Coordinate endPt) {
@@ -346,7 +348,7 @@
         Coordinate p1 = startPt;
         Coordinate p2 = endPt;
 
-        double d = 0.0D;
+        double d;
         LineSegment ls = new LineSegment(p1, p2);
         d = ls.angle();
         double DEG = 90.0D - d * 57.295779513082323D;

Modified: 
plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/ImageCellRenderer.java
===================================================================
--- 
plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/ImageCellRenderer.java
     2018-01-05 13:34:20 UTC (rev 5665)
+++ 
plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/ImageCellRenderer.java
     2018-01-07 21:02:59 UTC (rev 5666)
@@ -9,6 +9,7 @@
 import javax.swing.JList;
 import javax.swing.SwingConstants;
 
+@Deprecated
 public class ImageCellRenderer extends DefaultListCellRenderer {
 
     /**

Modified: 
plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/SaveBlockPlugIn.java
===================================================================
--- 
plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/SaveBlockPlugIn.java
       2018-01-05 13:34:20 UTC (rev 5665)
+++ 
plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/SaveBlockPlugIn.java
       2018-01-07 21:02:59 UTC (rev 5666)
@@ -3,12 +3,9 @@
 import java.awt.Dimension;
 import java.awt.GridBagLayout;
 import java.io.File;
-import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Iterator;
-import java.util.List;
 
-import javax.swing.DefaultComboBoxModel;
 import javax.swing.ImageIcon;
 import javax.swing.JLabel;
 import javax.swing.JPanel;
@@ -20,9 +17,7 @@
 import org.saig.core.gui.swing.sldeditor.util.FormUtils;
 
 import com.vividsolutions.jts.geom.Coordinate;
-import com.vividsolutions.jts.geom.Envelope;
 import com.vividsolutions.jts.geom.Geometry;
-import com.vividsolutions.jts.geom.GeometryFactory;
 import com.vividsolutions.jump.I18N;
 import com.vividsolutions.jump.feature.Feature;
 import com.vividsolutions.jump.geom.CoordUtil;
@@ -37,28 +32,35 @@
 import com.vividsolutions.jump.workbench.ui.TaskFrame;
 
 public class SaveBlockPlugIn extends AbstractPlugIn {
+
     public static ImageIcon ICON = IconLoader.icon("textblock/block_save.png");
-    public static final String NAME = I18NPlug
+
+    private static final String NAME = I18NPlug
             .getI18N("org.openjump.core.ui.plugins.block.SaveBlockPlugIn");
-    public static final String Warning1 = I18NPlug
+    private static final String Warning1 = I18NPlug
             
.getI18N("org.openjump.core.ui.plugins.block.SaveBlockPlugIn.description-title");
-    public static final String Warning2 = I18NPlug
+    private static final String Warning2 = I18NPlug
             
.getI18N("org.openjump.core.ui.plugins.block.SaveBlockPlugIn.warning-positive");
-    public static final String Warning3 = I18NPlug
+    private static final String Warning3 = I18NPlug
             
.getI18N("org.openjump.core.ui.plugins.block.SaveBlockPlugIn.warning-negative");
-    public static final String Description = I18NPlug
+    private static final String Description = I18NPlug
             
.getI18N("org.openjump.core.ui.plugins.block.SaveBlockPlugIn.description");
-    static JTextField jTextField_wktOut = new JTextField();
-    static JPanel jpanel = new JPanel(new GridBagLayout());
-    static JLabel jLabel = new JLabel();
-    private static String OUTPUT_FILE = I18NPlug
-            
.getI18N("org.openjump.core.ui.plugins.block.SaveBlockPlugIn.dialog");
-    public static final String blockFolder = "VertexImages";
-    Geometry geomSelected = null;
 
+    private BlockPanel blockPanel;
+    private JTextField jTextField_wktOut;
+
+
+    private String blockFolder = "VertexImages";
+    private Geometry geomSelected = null;
+
+    public SaveBlockPlugIn(BlockPanel blockPanel) {
+        super();
+        this.blockPanel = blockPanel;
+        this.jTextField_wktOut =  new JTextField();
+    }
+
     @Override
     public String getName() {
-
         String tooltip = "";
         tooltip = "<HTML><BODY>";
         tooltip += "<DIV style=\"width: 320px; text-justification: 
justify;\">";
@@ -89,7 +91,6 @@
                 .add(checkFactory.createAtLeastNItemsMustBeSelectedCheck(1));
     }
 
-    @SuppressWarnings("unchecked")
     @Override
     public boolean execute(PlugInContext context) throws Exception {
         reportNothingToUndoYet(context);
@@ -117,7 +118,7 @@
                 MultiInputDialog dialog = new MultiInputDialog(
                         context.getWorkbenchFrame(), NAME, true);
 
-                dialog.addRow(MainPanel(context));
+                dialog.addRow(createMainPanel());
 
                 GUIUtil.centreOnWindow(dialog);
                 dialog.setVisible(true);
@@ -190,47 +191,10 @@
                     }
 
                     context.getWorkbenchFrame().setStatusMessage(Warning2);
-                    //   File file = new File(filenamedir + ".wkt");
-                    //   BlockPanel.blocks.add(file.getName());
 
-
-                    ///     BlockPanel.model.removeAllElements();
-
-                    ///     BlockPanel.chooseBox.setModel(new 
DefaultComboBoxModel(BlockPanel.listOfBlockFiles(context).toArray()));
-                    ///      BlockPanel.chooseBlockPanel(context).repaint();
-
-
-                    DefaultComboBoxModel model = (DefaultComboBoxModel) 
BlockPanel.chooseBox.getModel();
-                    // removing old data
-                    model.removeAllElements();
-
-                    for (String item :  listOfBlockFiles()) {
-                        model.addElement(item);
+                    if (blockPanel != null) {
+                        blockPanel.initComboBox(context);
                     }
-
-                    // setting model with new data
-                    BlockPanel.chooseBox.setModel(model);
-                    BlockPanel.chooseBox.revalidate();
-                    //    BlockPanel.chooseBlockPanel(context).repaint();
-
-
-
-
-
-    /*               for (Iterator<?> i = BlockPanel.listOfBlockFiles(context)
-                             .iterator(); i.hasNext();) {
-                       name2 = i.next();
-
-                        BlockPanel.model.addElement((String) name2);
-                   }
-
-                    BlockPanel.chooseBox.revalidate();
-
-
-
-                   BlockPanel.chooseBox.repaint();
-                   Integer index = BlockPanel.model.getIndexOf(name2);
-                BlockPanel.chooseBox.setSelectedItem(index); */
                 }
 
 
@@ -241,7 +205,11 @@
         }
     }
 
-    public static JPanel MainPanel(PlugInContext context) {
+    private JPanel createMainPanel() {
+        JPanel jpanel = new JPanel(new GridBagLayout());
+        JLabel jLabel = new JLabel();
+        String OUTPUT_FILE = I18NPlug
+                
.getI18N("org.openjump.core.ui.plugins.block.SaveBlockPlugIn.dialog");
         jLabel.setText(OUTPUT_FILE);
         jTextField_wktOut.setEditable(true);
         jTextField_wktOut.setPreferredSize(new Dimension(250, 20));
@@ -249,59 +217,4 @@
         return jpanel;
     }
 
-
-    @SuppressWarnings("unchecked")
-    public  List<String> listOfBlockFiles() {
-        File pluginDir =JUMPWorkbench.getInstance().getContext().getWorkbench()
-                .getPlugInManager().getPlugInDirectory();
-        String wd = pluginDir.getAbsolutePath();
-        blocks = new ArrayList<String>();
-
-        blocks.add(square);
-        blocks.add(circle);
-        blocks.add(triangle);
-        blocks.add(cross);
-        blocks.add(star);
-        try {
-            String block_folder = wd + File.separator + blockFolder;
-            File directory = new File(block_folder);
-            // get all the files from a directory
-            File[] fList = directory.listFiles();
-            String fileName = null;
-            for (File file : fList) {
-                if (file.isFile()) {
-                    String ext = null;
-                    String s = file.getName();
-                    int i = s.lastIndexOf('.');
-                    if (i > 0 && i < s.length() - 1) {
-                        ext = s.substring(i + 1).toUpperCase();
-                    }
-                    if (ext.equals("WKT"))
-                        fileName = file.getName();
-                    int pos = fileName.lastIndexOf(".");
-                    if (pos > 0) {
-                        fileName = fileName.substring(0, pos);
-                        fileName.substring(pos, fileName.length());
-                    }
-                    blocks.add(fileName);
-                }
-            }
-
-        } catch (Exception ex) {
-            ex.printStackTrace();
-        }
-        return blocks;
-    }
-    public   List blocks;
-    public   String triangle = I18N
-            .get("deejump.ui.style.RenderingStylePanel.triangle");
-    public  String square = I18N
-            .get("deejump.ui.style.RenderingStylePanel.square");
-    public   String hexagon = "hexagon";
-    public   String cross = I18N
-            .get("deejump.ui.style.RenderingStylePanel.cross");
-    public  String star = I18N
-            .get("deejump.ui.style.RenderingStylePanel.star");
-    public String circle = I18N
-            .get("deejump.ui.style.RenderingStylePanel.circle");
 }
\ No newline at end of file

Modified: 
plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/language/cadtoolbox_fr.properties
===================================================================
--- 
plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/language/cadtoolbox_fr.properties
        2018-01-05 13:34:20 UTC (rev 5665)
+++ 
plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/language/cadtoolbox_fr.properties
        2018-01-07 21:02:59 UTC (rev 5666)
@@ -196,9 +196,9 @@
 org.openjump.core.ui.plugins.block.dialog.font-rotation-message=D\xE9finir 
l'orientation en degr\xE9s (sens horaire)
 org.openjump.core.ui.plugins.block = Blocs
 org.openjump.core.ui.plugins.block.DrawblockTool = Dessiner un bloc
-org.openjump.core.ui.plugins.block.DrawblockTool.description = Ins\xE9rer un 
bloc en cliquant dans la vue.\n\ La dimension et l'orientation du bloc doivent 
\xEAtre d\xE9finis ci-dessous avant de cliquer dans la vue
+org.openjump.core.ui.plugins.block.DrawblockTool.description = Ins\xE9rer un 
bloc en cliquant dans la vue.\n\ La dimension (%) et l'orientation du bloc 
doivent \xEAtre d\xE9finis ci-dessous avant de cliquer dans la vue
 org.openjump.core.ui.plugins.block.DrawOrientedBlockTool = Dessiner un bloc 
orient\xE9
-org.openjump.core.ui.plugins.block.DrawOrientedBlockTool.description = 
Ins\xE9rer un bloc puis d\xE9fini son orientation par un deuxi\xE8me clic.\n\ 
La dimension et l'orientation du bloc doivent \xEAtre d\xE9finis ci-dessous 
avant de cliquer dans la vue
+org.openjump.core.ui.plugins.block.DrawOrientedBlockTool.description = 
Ins\xE9rer un bloc puis d\xE9finir son orientation par un deuxi\xE8me clic.\n\ 
La dimension et l'orientation du bloc doivent \xEAtre d\xE9finis ci-dessous 
avant de cliquer dans la vue
 org.openjump.core.ui.plugins.block.SaveBlockPlugIn = Sauvegarder les 
g\xE9om\xE9tries s\xE9lectionn\xE9es en tant que bloc/symbol
 org.openjump.core.ui.plugins.block.SaveBlockPlugIn.dialog = Nom du bloc
 
org.openjump.core.ui.plugins.block.SaveBlockPlugIn.description-title=S\xE9lectionner
 une g\xE9om\xE9trie unique
@@ -210,7 +210,7 @@
 org.openjump.core.ui.plugins.annotation.dialog.font-rotation-message= 
D\xE9finir l'orientation du bloc en degr\xE9s (sens horaire)
 org.openjump.core.ui.plugins.block.dialog-dimension-message=D\xE9finir la 
dimension du bloc (pourcentage)
 org.openjump.core.ui.plugins.block.define-dimension = D\xE9finir la dimension 
du bloc
-org.openjump.core.ui.plugins.block.define-dimension-description=D\xE9finir la 
dimension du bloc (pourcentage). 100% correspond \xE0 une taille d'environ 
16-80 en unit\xE9s de la carte
+org.openjump.core.ui.plugins.block.define-dimension-description=D\xE9finir la 
dimension du bloc (pourcentage). 100% correspond \xE0 la taille d'origine du 
bloc dans le mod\xE8le
 org.openjump.core.ui.plugins.block.dialog-dimension = Dimension
 org.openjump.core.ui.plugins.block.dialog-rotation = Orientation
 org.openjump.core.ui.tools.General.Nearby  = Proximit\xE9


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

Reply via email to