Revision: 5645 http://sourceforge.net/p/jump-pilot/code/5645 Author: michaudm Date: 2017-12-24 12:20:41 +0000 (Sun, 24 Dec 2017) Log Message: ----------- Commit last changes from Peppe + an ant build file for CAD tool
Modified Paths: -------------- plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/BlockPanel.java plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/GeometryUtils.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/icon/IconLoader.java plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/utils/EditUtils.java Added Paths: ----------- plug-ins/CADExtension/trunk/build.xml plug-ins/CADExtension/trunk/lib/ Copied: plug-ins/CADExtension/trunk/build.xml (from rev 5643, plug-ins/JumpJGraphT/trunk/build.xml) =================================================================== --- plug-ins/CADExtension/trunk/build.xml (rev 0) +++ plug-ins/CADExtension/trunk/build.xml 2017-12-24 12:20:41 UTC (rev 5645) @@ -0,0 +1,99 @@ + +<project name="cad-tools" default="compile" basedir="."> + + <!--************************************************************************ + **************************************************************************** + ** PROPERTIES ** + **************************************************************************** + *************************************************************************--> + + <property name="name" value="cad-tools"/> + + <!-- PROPERTIES : MAIN ARCHITECTURE --> + <property name="src" value="src" /> + <property name="bin" value="bin" /> + <property name="lib" value="lib" /> + <property name="build" value="build" /> + <property name="dist" value="dist" /> + <property name="javadoc" value="javadoc" /> + + <!-- Versions + 0.5 : first version built from ant + --> + <property name="version" value="0.5" /> + + <!-- =================================================================== --> + <!-- Defines the classpath used for compilation and test. --> + <!-- =================================================================== --> + <path id="classpath"> + <fileset dir="${lib}"> + <include name="**/*.jar"/> + </fileset> + </path> + + <target name="clean" id="clean"> + <delete dir="${build}"/> + </target> + + <!-- =================================================================== --> + <!-- compile cad-extension --> + <!-- =================================================================== --> + <target name="compile" id="compile" depends="clean"> + <mkdir dir="${build}"/> + <javac encoding="ISO-8859-1" destdir="${build}" debug="true" deprecation="false" nowarn="true" source="1.7" target="1.7"> + <src path="${src}"/> + <classpath refid="classpath"/> + <include name="**/*.java"/> + <include name="**/*.properties"/> + <include name="**/*.png"/> + <include name="**/*.gif"/> + </javac> + <copy todir="${build}"> + <fileset dir="${src}"> + <include name="**/*.png"/> + <include name="**/*.properties"/> + <include name="**/*.gif"/> + </fileset> + </copy> + </target> + + <!-- =================================================================== --> + <!-- jar cad-extension --> + <!-- =================================================================== --> + <target name="jar" id="jar" depends="compile"> + <mkdir dir="${dist}"/> + <jar basedir="${build}" jarfile="${dist}/${name}-${version}.jar"> + <include name="es/axios/**/*"/> + <include name="es/kosmo/**/*"/> + <include name="org/openjump/advancedtools/**/*"/> + <include name="org/openjump/core/ui/renderer/style/**/*"/> + </jar> + </target> + + <!-- =================================================================== --> + <!-- javadoc cad-extension --> + <!-- =================================================================== --> + <target name="javadoc" depends="compile"> + <mkdir dir="${javadoc}"/> + <javadoc destdir="${javadoc}" use="true"> + <classpath refid="classpath"/> + <packageset dir="${src}"> + <include name="es/**"/> + <include name="org/**"/> + </packageset> + </javadoc> + </target> + + <!-- =================================================================== --> + <!-- dist cad-extension --> + <!-- =================================================================== --> + <target name="zip-cad-tools" id="zip-cad-tools" depends="jar, javadoc"> + <zip basedir="." zipfile="${dist}/${name}-${version}.zip"> + <include name="src/**"/> + <include name="javadoc/**"/> + <include name="${dist}/${name}-${version}.jar"/> + <include name="build.xml"/> + </zip> + </target> + +</project> \ No newline at end of file Modified: plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/BlockPanel.java =================================================================== --- plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/BlockPanel.java 2017-12-16 11:19:52 UTC (rev 5644) +++ plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/BlockPanel.java 2017-12-24 12:20:41 UTC (rev 5645) @@ -49,7 +49,7 @@ @SuppressWarnings("rawtypes") public static JComboBox chooseBox; - public static DefaultComboBoxModel<String> model = new DefaultComboBoxModel<String>(); + public static DefaultComboBoxModel model = new DefaultComboBoxModel(); public static JPanel block_panel = new JPanel(new GridLayout(0, 1)); public static JPanel option_panel = new JPanel(new GridLayout(0, 1)); @@ -79,12 +79,12 @@ public static String star = I18N .get("deejump.ui.style.RenderingStylePanel.star"); public static SpinnerModel rotationModel = new SpinnerNumberModel(0, // initial - // value + // value 0, // min 359, // max 1); public static SpinnerModel dimensionModel = new SpinnerNumberModel(100, // initial - // value + // value 10, // min 400, // max 10); @@ -94,13 +94,13 @@ private static WorkbenchToolBar toolBar = new WorkbenchToolBar(null) { /** - * + * */ private static final long serialVersionUID = 1L; @Override public JButton addPlugIn(Icon icon, PlugIn plugIn, - EnableCheck enableCheck, WorkbenchContext workbenchContext) { + EnableCheck enableCheck, WorkbenchContext workbenchContext) { return super.addPlugIn(icon, plugIn, enableCheck, workbenchContext); } @@ -146,7 +146,7 @@ public static List<String> list; @SuppressWarnings({ "unchecked", "rawtypes" }) - public JPanel chooseBlockPanel(PlugInContext context) { + public static JPanel chooseBlockPanel(PlugInContext context) { chooseBox = new JComboBox(new Vector(listOfBlockFiles(context))); @@ -153,12 +153,12 @@ Dimension d = new Dimension(125, chooseBox.getPreferredSize().height); chooseBox.setPreferredSize(d); - BlockCellRenderer renderer = new BlockCellRenderer(); + /* BlockCellRenderer renderer = new BlockCellRenderer(); chooseBox.setRenderer(renderer); list = listOfBlockFiles(context); HashMap<Object, Icon> icons = ListOfBlocksIcons(); renderer.setTooltips(list); - renderer.setIcons(icons); + renderer.setIcons(icons);*/ model = (DefaultComboBoxModel) chooseBox.getModel(); JPanel test_block_panel = new JPanel(new GridBagLayout()); @@ -190,7 +190,7 @@ } @SuppressWarnings("unchecked") - public static List<String> listOfBlockFiles(PlugInContext context) { + public static List<String> listOfBlockFiles(PlugInContext context) { File pluginDir = context.getWorkbenchContext().getWorkbench() .getPlugInManager().getPlugInDirectory(); String wd = pluginDir.getAbsolutePath(); @@ -312,7 +312,7 @@ tooltip += "<DIV style=\"width: 200px; text-justification: justify;\">"; tooltip += "<b>" + I18NPlug - .getI18N("org.openjump.core.ui.plugins.block.define-dimension") + .getI18N("org.openjump.core.ui.plugins.block.define-dimension") + "</b>" + "<br>"; tooltip += I18NPlug .getI18N("org.openjump.core.ui.plugins.block.define-dimension-description") @@ -335,4 +335,4 @@ return icon; } -} +} \ No newline at end of file Modified: plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/GeometryUtils.java =================================================================== --- plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/GeometryUtils.java 2017-12-16 11:19:52 UTC (rev 5644) +++ plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/GeometryUtils.java 2017-12-24 12:20:41 UTC (rev 5645) @@ -7,12 +7,11 @@ import java.io.Writer; import java.util.List; -import bsh.ParseException; - import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.CoordinateFilter; import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.io.WKTFileReader; +import com.vividsolutions.jts.io.ParseException; import com.vividsolutions.jump.geom.CoordUtil; public class GeometryUtils { @@ -20,9 +19,8 @@ /** * Method to scale a selected geometry of a scale factor * - * @param input - * geometry - * @param double. Scale factor (50 = half, 100 = no rescale, 200 = scale two + * @param geometry input geometry + * @param scale Scale factor (50 = half, 100 = no rescale, 200 = scale two * times) */ public static void scaleGeometry(Geometry geometry, final double scale) { @@ -41,10 +39,8 @@ /** * Method to rotate a geometry of a defined angle * - * @param input - * geometry - * @param angle - * in degree + * @param geometry input geometry + * @param angle in degree */ public static void rotateGeometry(Geometry geometry, final double angle) { final Coordinate center = geometry.getCentroid().getCoordinate(); @@ -69,12 +65,9 @@ * Method to counterclock wise rotate a geometry of a defined angle and * setting center of rotation * - * @param input - * geometry - * @param angle - * in degree - * @param coordinate - * center of rotation + * @param geometry input geometry + * @param angle in degree + * @param center coordinate center of rotation */ public static void rotateGeometry(Geometry geometry, final double angle, @@ -111,10 +104,8 @@ /** * Method to counterclock wise rotate a geometry of a defined angle * - * @param input - * geometry - * @param angle - * in degree + * @param geometry input geometry + * @param angle in degree */ public static void rotate_counterclockwise_Geometry(Geometry geometry, final double angle) { @@ -138,10 +129,8 @@ /** * Method to clock wise rotate a geometry of a defined angle * - * @param input - * geometry - * @param angle - * in degree + * @param geometry input geometry + * @param angle in degree */ public static void rotate_clockwise_Geometry(Geometry geometry, final double angle) { @@ -166,8 +155,7 @@ * Move a geometry to a defined coordinate * * @param geometry - * @param coordinate - * to move + * @param displacement */ public static void centerGeometry(final Geometry geometry, final Coordinate displacement) { @@ -184,8 +172,7 @@ * Translate a geometry to a defined coordinate * * @param geometry - * @param coordinate - * to move + * @param displacement */ protected void translateGeometry(Geometry geometry, @@ -206,8 +193,6 @@ * Mirror a geometry to a defined coordinate * * @param geometry - * @param coordinate - * to move */ public static void mirrorY(Geometry geometry) { @@ -225,14 +210,13 @@ /** * Reads a WKT file and returns the first geometry. * - * @param filenamedir + * @param wktpath geometry as a wkt String * @return * @throws ParseException * @throws IOException * @throws com.vividsolutions.jts.io.ParseException */ - public static Geometry geom(String wktpath) throws ParseException, - IOException, com.vividsolutions.jts.io.ParseException { + public static Geometry geom(String wktpath) throws IOException, ParseException { com.vividsolutions.jts.io.WKTReader reader = new com.vividsolutions.jts.io.WKTReader(); WKTFileReader fileReader = new WKTFileReader(wktpath, reader); @SuppressWarnings("rawtypes") Modified: plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/ImageCellRenderer.java =================================================================== --- plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/ImageCellRenderer.java 2017-12-16 11:19:52 UTC (rev 5644) +++ plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/ImageCellRenderer.java 2017-12-24 12:20:41 UTC (rev 5645) @@ -25,7 +25,7 @@ } @Override - public Component getListCellRendererComponent(JList<?> list, Object value, + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); Modified: plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/SaveBlockPlugIn.java =================================================================== --- plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/SaveBlockPlugIn.java 2017-12-16 11:19:52 UTC (rev 5644) +++ plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/block/SaveBlockPlugIn.java 2017-12-24 12:20:41 UTC (rev 5645) @@ -3,9 +3,12 @@ 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; @@ -137,22 +140,22 @@ geomSelected = featureSelected.getGeometry(); } - Geometry targetGeom = new GeometryFactory() - .createLineString(new Coordinate[] { - new Coordinate(0, 0), - new Coordinate(20, 20) }); - double targetLength = targetGeom.getLength(); - double scale = 0; + // Geometry targetGeom = new GeometryFactory() + // .createLineString(new Coordinate[] { + // new Coordinate(0, 0), + // new Coordinate(0, 8.49) }); + // double targetLength = targetGeom.getLength(); + // double scale = 0; - Envelope envSelected = geomSelected.getEnvelopeInternal(); + // Envelope envSelected = geomSelected.getEnvelopeInternal(); - Geometry sourceGeom = new GeometryFactory() - .createLineString(new Coordinate[] { - new Coordinate(envSelected.getMinX(), - envSelected.getMinY()), - new Coordinate(envSelected.getMaxY(), - envSelected.getMaxY()) }); - double sourceLength = sourceGeom.getLength(); + // Geometry sourceGeom = new GeometryFactory() + // .createLineString(new Coordinate[] { + // new Coordinate(envSelected.getMinX(), + // envSelected.getMinY()), + // new Coordinate(envSelected.getMaxY(), + // envSelected.getMaxY()) }); + // double sourceLength = sourceGeom.getLength(); /* * if (sourceLength>22){ scale = @@ -168,10 +171,10 @@ Coordinate displacement = CoordUtil.subtract( new Coordinate(0, 0), coord); - scale = (targetLength / sourceLength) * 100; + // scale = (targetLength / sourceLength); GeometryUtils.centerGeometry(newGeom, displacement); - GeometryUtils.scaleGeometry(newGeom, scale); + // GeometryUtils.scaleGeometry(newGeom, scale); filenamedir = wd + File.separator + blockFolder + File.separator + filename; @@ -187,24 +190,50 @@ } context.getWorkbenchFrame().setStatusMessage(Warning2); - File file = new File(filenamedir + ".wkt"); - BlockPanel.blocks.add(file.getName()); - BlockPanel.model.removeAllElements(); - Object name2 = ""; - for (Iterator<?> i = BlockPanel.listOfBlockFiles(context) - .iterator(); i.hasNext();) { - name2 = i.next(); + // File file = new File(filenamedir + ".wkt"); + // BlockPanel.blocks.add(file.getName()); - BlockPanel.model.addElement((String) name2); + + /// 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); } - BlockPanel.chooseBox.revalidate(); // for JFrame up to Java7 - // is - // there only validate() - BlockPanel.chooseBox.repaint(); - Integer index = BlockPanel.model.getIndexOf(name2); - BlockPanel.chooseBox.setSelectedItem(index); + // 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); */ } + + } catch (Exception ex) { WorkbenchUtils.Logger(this.getClass(), ex); } @@ -220,4 +249,59 @@ 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/icon/IconLoader.java =================================================================== --- plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/icon/IconLoader.java 2017-12-16 11:19:52 UTC (rev 5644) +++ plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/icon/IconLoader.java 2017-12-24 12:20:41 UTC (rev 5645) @@ -78,10 +78,9 @@ URL urlIcon = IconLoader.class.getResource(filename); if (urlIcon == null) { if (useDefaultForNull) { - LOGGER.warn(I18N - .getMessage( - "com.vividsolutions.jump.workbench.ui.images.IconLoader.The-icon-{0}-has-not-been-found-default-icon-will-be-used", - new Object[] { filename })); + LOGGER.warn(I18N.getMessage( + "com.vividsolutions.jump.workbench.ui.images.IconLoader.The-icon-{0}-has-not-been-found-default-icon-will-be-used", + new Object[] { filename })); return DEFAULT_UNKNOW_ICON; } else { return null; Modified: plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/utils/EditUtils.java =================================================================== --- plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/utils/EditUtils.java 2017-12-16 11:19:52 UTC (rev 5644) +++ plug-ins/CADExtension/trunk/src/org/openjump/advancedtools/utils/EditUtils.java 2017-12-24 12:20:41 UTC (rev 5645) @@ -176,7 +176,7 @@ /** * It get geometries adjacent to a given one * - * @param geometry + * @param simplyGeometryToProcess * @param layer * @return List of adjacent geometries * @throws Exception @@ -405,9 +405,9 @@ /** * It gets the existing geometry at the selected point * - * @param Coordinate - * @param Layer - * @param Scale + * @param sc source coordinate + * @param l layer + * @param scale Scale factor * @return Feature * @throws Exception */ @@ -480,19 +480,17 @@ /** * It divide the lineString from the indicated coordinate * - * @param lineString - * lineString to divide - * @param Coordinates - * of the point to divide + * @param line lineString to divide + * @param coord Coordinates of the point to divide * @return LineString[] - two fragments of the Linestring */ - public static LineString[] divideLineString(LineString line, Coordinate cord) { + public static LineString[] divideLineString(LineString line, Coordinate coord) { Coordinate[] coordinates = line.getCoordinates(); int i = 0; boolean enc = false; while (!enc && i < coordinates.length) { - if (coordinates[i].equals(cord)) + if (coordinates[i].equals(coord)) enc = true; else i++; @@ -886,7 +884,6 @@ * (sobrescribiendo la lista de geometrias con sus versiones nodadas) y * devuelve una coleccion de poligonos formados tras la poligonalizacion * - * @param nodeSet * @param geometryList * lista de geometrias a nodar * @return lista de poligonos formados tras la poligonalizacion @@ -994,13 +991,13 @@ // Try to snap them together and see the result snapGeometries(geometries, DEFAULT_SNAP_TOLERANCE); - LOGGER.info(geometries); + LOGGER.info(geometries.toString()); geom1 = reader .read("LINESTRING(547272.036 4704746, 547329.389 4704713.573)"); - geom2 = reader.read("POINT(547310.439 4704724.287)"); - LOGGER.info("Distancia = " + geom2.distance(geom1)); + geom2 = reader.read("POINT(547310.439 4704724.287)"); + LOGGER.info("Distancia = " + geom2.distance(geom1)); } catch (ParseException e) { - LOGGER.error("", e); + LOGGER.error("", e); } } @@ -1389,7 +1386,7 @@ } /** - * @param coordinateSequenceMap + * @param coordSequenceMap * the coordinateSequenceMap to set */ public void setCoordinateSequenceMap( @@ -1654,9 +1651,9 @@ * method is used whenever a collection of features is cloned for further * transformation (move, mirror, etc) * - * @param a + * @param features * collection of features - * @param feature + * @param targetFeatureSchema * schema from the original layer * @return collection with feature schema */ @@ -1676,8 +1673,8 @@ * Transfer a feature schema of a layer to a feature. This method is used * whenever feature is cloned for further transformation (move, mirror, etc) * - * @param feature - * @param feature + * @param original + * @param targetFeatureSchema * schema from the original layer * @return feature with feature schema */ ------------------------------------------------------------------------------ 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