diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..905fd4f
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+/target/
+.settings/*
+.project
+.classpath
\ No newline at end of file
diff --git a/distro-zip.xml b/distro-zip.xml
new file mode 100644
index 0000000..aa0556b
--- /dev/null
+++ b/distro-zip.xml
@@ -0,0 +1,30 @@
+
+ distro zip
+
+ zip
+
+ false
+
+
+
+ /
+ false
+
+ ${artifact}
+
+
+
+
+ /lib
+ false
+ runtime
+ true
+ false
+
+ org.openjump:OpenJUMP
+
+
+
+
\ No newline at end of file
diff --git a/doc/JumpChartUserGuide.pdf b/doc/JumpChartUserGuide.pdf
new file mode 100644
index 0000000..9283a47
Binary files /dev/null and b/doc/JumpChartUserGuide.pdf differ
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..146fca4
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,122 @@
+
+
+
+ 4.0.0
+ com.cadplan
+ jump-chart-extension
+ 2.1.0
+
+
+ 1.8
+ 1.8
+ UTF-8
+
+ [${git.branch}/${git.commit.id.abbrev}/${git.build.time}]
+
+
+
+
+ ojrepo
+ OpenJUMP Snapshot Repository
+ https://ojrepo.soldin.de/
+
+
+
+
+
+ org.openjump
+ OpenJUMP
+ 2.0-main-SNAPSHOT
+
+
+
+
+
+
+ src/main/resources
+
+
+ src/main/resources
+
+ com/cadplan/jump_chart/language/
+
+ true
+
+
+
+
+ maven-assembly-plugin
+ 3.3.0
+
+ false
+
+
+
+ distro zip
+ package
+
+
+ distro-zip.xml
+
+ false
+
+
+ single
+
+
+
+
+
+ pl.project13.maven
+ git-commit-id-plugin
+ 4.9.10
+
+
+
+
+ fetch git properties of current branch
+
+ revision
+
+ validate
+
+
+
+ true
+
+ ^git.branch$
+ ^git.build.(time|version|(number(|.unique)))$
+ ^git.commit.(id.(abbrev|full)|message.short)$
+ ^git.dirty$
+
+
+
+
+ net.nicoulaj.maven.plugins
+ checksum-maven-plugin
+ 1.10
+
+
+
+ files
+
+ package
+
+
+
+ ${project.build.directory}
+
+ ${project.build.finalName}.zip
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/com/cadplan/jump_chart/designer/GridBagDesigner.java b/src/main/java/com/cadplan/jump_chart/designer/GridBagDesigner.java
new file mode 100644
index 0000000..05efc7d
--- /dev/null
+++ b/src/main/java/com/cadplan/jump_chart/designer/GridBagDesigner.java
@@ -0,0 +1,223 @@
+/*
+ * The Unified Mapping Platform (JUMP) is an extensible, interactive GUI
+ * for visualizing and manipulating spatial features with geometry and attributes.
+ *
+ * Copyright (C) 2006 Cadplan
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+package com.cadplan.jump_chart.designer;
+//===================================================
+// GridBagDesigner
+//===================================================
+
+
+
+
+import java.awt.*;
+import javax.swing.*;
+
+/**
+ * @author Geoffrey G. Roy
+ * @version 1.0
+ */
+
+
+public class GridBagDesigner
+{
+
+
+
+
+private GridBagLayout layout;
+private GridBagConstraints constraints;
+private Container container;
+
+
+
+ /**
+ * Constructor for GridBagDesgner
+ *
+ * @param container
+ */
+public GridBagDesigner(Container container)
+{
+ layout = new GridBagLayout();
+ constraints = new GridBagConstraints();
+ container.setLayout(layout);
+ this.container = container;
+ setDefaults();
+}
+
+
+
+ /**
+ * Adds a component using currrent settings
+ *
+ * @param component
+ */
+
+public void addComponent(Component component)
+{
+ layout.setConstraints(component, constraints);
+ container.add(component);
+ setDefaults();
+}
+ public void addComponentRetain(Component component)
+{
+ layout.setConstraints(component, constraints);
+ container.add(component);
+}
+
+ /**
+ * Adds a JComponent using current settings and fixes
+ * size to xSize * ySize
+ *
+ * @param component
+ * @param xSize
+ * @param ySize
+ */
+public void addComponent(JComponent component, int xSize, int ySize)
+{
+ Dimension size = new Dimension(xSize, ySize);
+ component.setMinimumSize(size);
+ component.setMaximumSize(size);
+ component.setPreferredSize(size);
+ layout.setConstraints(component, constraints);
+ container.add(component);
+ setDefaults();
+}
+
+public void addComponentRetain(JComponent component, int xSize, int ySize)
+{
+ Dimension size = new Dimension(xSize, ySize);
+ component.setMinimumSize(size);
+ component.setMaximumSize(size);
+ component.setPreferredSize(size);
+ layout.setConstraints(component, constraints);
+ container.add(component);
+}
+
+public void resetLayout()
+{
+ setDefaults();
+}
+
+
+ /**
+ * Sets gid position
+ * Default is (0,0);
+ *
+ * @param gridx
+ * @param gridy
+ */
+public void setPosition(int gridx, int gridy)
+{
+ constraints.gridx = gridx;
+ constraints.gridy = gridy;
+}
+
+
+ /**
+ * Sets grid span
+ * Defaults are (1,1)
+ *
+ * @param gridwidth
+ * @param gridheight
+ */
+public void setSpan(int gridwidth, int gridheight)
+{
+ constraints.gridwidth = gridwidth;
+ constraints.gridheight = gridheight;
+}
+
+
+ /**
+ * Sets cell weights
+ * Defaults are (0.0,0.0)
+ *
+ * @param weightx
+ * @param weighty
+ */
+public void setWeight(double weightx, double weighty)
+{
+ constraints.weightx = weightx;
+ constraints.weighty = weighty;
+}
+
+
+ /**
+ * Sets cell fill type as one of:
+ * GridBagConstraints.{NONE, VERTICAL, HORIZONTAL, BOTH}
+ * Default is NONE
+ *
+ * @param fill
+ */
+public void setFill(int fill)
+{
+ constraints.fill = fill;
+}
+
+
+ /**
+ * Sets cell anchor type as one of:
+ * GridBagConstraints.{NORTH, NORTHEAST, EAST, SOUTHEAST, SOUTH, SOUTHWEST, WEST, NORTHWEST, CENTER}
+ * Default is CENTER
+ *
+ * @param anchor
+ */
+public void setAnchor(int anchor)
+{
+ constraints.anchor = anchor;
+}
+
+
+
+ /**
+ * Sets cell insets
+ * Defaults are (0,0,0,0)
+ *
+ * @param top
+ * @param left
+ * @param bottom
+ * @param right
+ */
+public void setInsets(int top, int left, int bottom, int right)
+{
+ constraints.insets = new Insets(top, left, bottom, right);
+}
+
+
+ /**
+ * Sets cell defaults
+ *
+ */
+private void setDefaults()
+{
+ constraints.gridx = 0;
+ constraints.gridy = 0;
+ constraints.gridwidth = 1;
+ constraints.gridheight = 1;
+ constraints.fill = GridBagConstraints.NONE;
+ constraints.anchor = GridBagConstraints.CENTER;
+ constraints.weightx = 0.0;
+ constraints.weighty = 0.0;
+ constraints.insets = new Insets(0,0,0,0);
+
+}
+
+
+}
diff --git a/src/main/java/com/cadplan/jump_chart/fileio/FileChooser.java b/src/main/java/com/cadplan/jump_chart/fileio/FileChooser.java
new file mode 100644
index 0000000..e0d92d5
--- /dev/null
+++ b/src/main/java/com/cadplan/jump_chart/fileio/FileChooser.java
@@ -0,0 +1,138 @@
+package com.cadplan.jump_chart.fileio;
+
+
+
+import javax.swing.*;
+import javax.swing.filechooser.FileFilter;
+import java.io.File;
+import java.awt.*;
+import java.util.Properties;
+
+/**
+ * User: geoff
+ * Date: 5/04/2006
+ * Time: 12:54:42
+ * Copyright 2005 Geoffrey G Roy.
+ */
+public class FileChooser
+{
+ JFileChooser chooser;
+ public String fileName;
+ public String dirName;
+
+ public FileChooser(Component parent, String defaultDirName, String defaultFileName,
+ String [] filterText, String info, int type)
+ {
+ int returnVal;
+ File dir;
+ Properties props = System.getProperties();
+ if(defaultDirName == null) dir = new File(props.getProperty("user.dir"));
+ else dir = new File(defaultDirName+File.separator);
+ chooser = new JFileChooser();
+ chooser.setDialogType(type);
+
+
+ MyFileFilter filter = new MyFileFilter(info, filterText);
+
+ chooser.setFileFilter(filter);
+ chooser.setCurrentDirectory(dir);
+ if(defaultFileName != null) chooser.setSelectedFile(new File(defaultFileName));
+
+ if(type == JFileChooser.OPEN_DIALOG)
+ {
+ returnVal= chooser.showOpenDialog(parent);
+ }
+ else
+ {
+ returnVal= chooser.showSaveDialog(parent);
+ }
+
+ if(returnVal == JFileChooser.APPROVE_OPTION)
+ {
+ fileName = chooser.getSelectedFile().getName();
+ if(type == JFileChooser.SAVE_DIALOG) fileName = addExtension(fileName,filterText);
+ dirName = chooser.getCurrentDirectory().getPath();
+ }
+ else
+ {
+ fileName = null;
+ }
+ }
+ public String getFile()
+ {
+ return fileName;
+ }
+ public String getDir()
+ {
+ return dirName;
+ }
+
+ private String addExtension(String name, String [] filterText)
+ {
+ boolean OK = false;
+ for (int i=0; i < filterText.length; i++)
+ {
+ String ext = filterText[i];
+ if(name.toLowerCase().endsWith("."+ext)) OK = true;
+ }
+ if(!OK) name = name + "." + filterText[0];
+ return name;
+ }
+}
+
+class MyFileFilter extends FileFilter
+{
+ String description;
+ String [] extensions;
+ boolean acceptAll = false;
+
+ public MyFileFilter(String description, String extension)
+ {
+ this(description, new String [] {extension});
+ }
+
+ public MyFileFilter(String description, String [] extensions)
+ {
+ if(description == null) this.description = "Files like: "+extensions[0];
+ else this.description = description;
+ this.extensions = (String []) extensions.clone();
+ toLower(this.extensions);
+ for(int i=0; i < this.extensions.length; i++)
+ {
+ if(this.extensions[i].equals("*")) acceptAll = true;
+ }
+ }
+
+ private void toLower(String [] sa)
+ {
+ for (int i=0, n = sa.length; i < n; i++)
+ {
+ sa[i] = sa[i].toLowerCase();
+ }
+ }
+
+ public String getDescription()
+ {
+ return description;
+ }
+
+ public boolean accept(File file)
+ {
+ if(file.isDirectory()) return true;
+ if(acceptAll) return true;
+ else
+ {
+ String path = file.getAbsolutePath().toLowerCase();
+ for (int i=0; i < extensions.length; i++)
+ {
+
+ String extension = extensions[i];
+ if(path.endsWith(extension) && (path.charAt(path.length() - extension.length()-1) == '.'))
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+}
diff --git a/src/main/java/com/cadplan/jump_chart/fileio/IconLoader.java b/src/main/java/com/cadplan/jump_chart/fileio/IconLoader.java
new file mode 100644
index 0000000..1b8aa9f
--- /dev/null
+++ b/src/main/java/com/cadplan/jump_chart/fileio/IconLoader.java
@@ -0,0 +1,105 @@
+package com.cadplan.jump_chart.fileio;
+
+//==================================================================
+//
+// IconLoader
+//
+//==================================================================
+//
+// This module is a part of the P-Coder package
+// �2002, Geoffrey G. Roy, School of Engineering, Murdoch University
+//==================================================================
+
+
+import java.awt.*;
+import java.net.*;
+import java.util.*;
+import java.io.*;
+import java.util.jar.*;
+import java.lang.*;
+
+
+public class IconLoader extends Component {
+ boolean debug = false;
+ Image image = null;
+ Properties prop = null;
+ MediaTracker tracker;
+ URL url, jarurl;
+ String appName;
+ String wd = "";
+
+
+ public IconLoader(String wd, String appName) {
+ this.wd = wd;
+ this.appName = appName;
+ }
+
+ public IconLoader(String appName) {
+
+ prop = System.getProperties();
+ wd = prop.getProperty("user.dir");
+ this.appName = appName;
+ }
+
+ public void setWD(String dirName) {
+ wd = dirName;
+ }
+
+ public Image loadImage(String name) {
+ tracker = new MediaTracker(this);
+ Image image = load(name);
+ return (image);
+
+ }
+
+
+ public Image load(String name) {
+
+
+ if (debug) System.out.println("User WD = " + wd);
+ String filename;
+ filename = "jar:file:" + wd + "/" + appName + ".jar!/" + "Resources/" + name;
+ if (debug) System.out.println("Loading from jar: " + filename);
+ try {
+ jarurl = new URL(filename);
+ // System.out.println("URL= "+jarurl);
+ JarURLConnection jarConnection = (JarURLConnection) jarurl.openConnection();
+ Manifest manifest = jarConnection.getManifest();
+ // System.out.println("Loading splash from JAR");
+
+ } catch (MalformedURLException e) {
+ if (debug) System.out.println("Jar file not found at " + wd);
+ } catch (IOException e) {
+
+
+ if (debug) System.out.println("Error opening Jar file at: " + wd);
+ if (debug) System.out.println("Jar file not found " + e);
+ if (debug) System.out.println("Error opening Jar file from URL, trying local file: " + e);
+ try {
+ String fname = "";
+ fname = "file:///" + wd + "/Classes/Resources/" + name;
+ if (debug) System.out.println("Loading from: " + fname);
+ jarurl = new URL(fname);
+ if (debug) System.out.println("Loading icon from GIF");
+ } catch (MalformedURLException e1) {
+ System.out.println("ERROR - " + e1);
+ }
+
+ }
+ if (debug) System.out.println("URL= " + jarurl);
+ image = Toolkit.getDefaultToolkit().getImage(jarurl);
+ try {
+ tracker.addImage(image, 1);
+ tracker.waitForID(1);
+ } catch (InterruptedException e) {
+ }
+
+ if (debug) System.out.println("Image size: " + image.getWidth(this) + ", " + image.getHeight(this));
+ if (image.getWidth(this) < 0) image = null;
+// Icon icon = new ImageIcon(image);
+ return (image);
+
+ }
+
+
+}
diff --git a/src/main/java/com/cadplan/jump_chart/fileio/TextFile.java b/src/main/java/com/cadplan/jump_chart/fileio/TextFile.java
new file mode 100644
index 0000000..5cdd496
--- /dev/null
+++ b/src/main/java/com/cadplan/jump_chart/fileio/TextFile.java
@@ -0,0 +1,123 @@
+package com.cadplan.jump_chart.fileio;
+
+import java.io.*;
+import java.util.Properties;
+
+/**
+ * User: geoff
+ * Date: 18/10/2006
+ * Time: 09:49:10
+ * Copyright 2005 Geoffrey G Roy.
+ */
+public class TextFile
+{
+ String fileName;
+ String dirName;
+ BufferedReader reader = null;
+ FileWriter writer = null;
+
+ public TextFile(String dirName, String fileName)
+ {
+ this.dirName = dirName;
+ Properties props = System.getProperties();
+ if(dirName == null) this.dirName = props.getProperty("user.dir");
+ this.fileName = fileName;
+ }
+
+ public boolean exists()
+ {
+ File file = new File(dirName+File.separator+fileName);
+ return file.exists();
+ }
+
+ public boolean openRead()
+ {
+ File file = new File(dirName+File.separator+fileName);
+
+ try
+ {
+ reader = new BufferedReader(new FileReader(file));
+ return true;
+ }
+ catch (FileNotFoundException ex)
+ {
+ return false;
+ }
+
+ }
+
+ public boolean openWrite()
+ {
+ File file = new File(dirName+File.separator+fileName);
+
+ try
+ {
+ writer = new FileWriter(file);
+ return true;
+ }
+ catch (IOException ex)
+ {
+ return false;
+ }
+ }
+
+ public String readLine()
+ {
+ try
+ {
+ return reader.readLine();
+ }
+ catch (IOException ex)
+ {
+ return null;
+ }
+ }
+
+ public String readAll()
+ {
+ String line = "";
+ StringBuffer sb = new StringBuffer();
+ try
+ {
+ while (line != null)
+ {
+ line = reader.readLine();
+ if(line != null) sb.append(line+"\n");
+ }
+ }
+ catch (IOException ex)
+ {
+ return sb.toString();
+ }
+ return sb.toString();
+ }
+
+ public boolean write(String s)
+ {
+ try
+ {
+ writer.write(s);
+ return true;
+ }
+ catch (IOException ex)
+ {
+ return false;
+ }
+ }
+
+ public void close()
+ { try
+ {
+ if(reader != null) reader.close();
+ else if(writer != null)
+ {
+ writer.flush();
+ writer.close();
+ }
+ }
+ catch (IOException ex)
+ {
+
+ }
+ }
+}
diff --git a/src/main/java/com/cadplan/jump_chart/jump/AttributeOrder.java b/src/main/java/com/cadplan/jump_chart/jump/AttributeOrder.java
new file mode 100644
index 0000000..b862323
--- /dev/null
+++ b/src/main/java/com/cadplan/jump_chart/jump/AttributeOrder.java
@@ -0,0 +1,169 @@
+/*
+ * The Unified Mapping Platform (JUMP) is an extensible, interactive GUI
+ * for visualizing and manipulating spatial features with geometry and attributes.
+ *
+ * Copyright (C) 2006 Cadplan
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+package com.cadplan.jump_chart.jump;
+
+import com.cadplan.jump_chart.designer.GridBagDesigner;
+import com.vividsolutions.jump.I18N;
+
+import javax.swing.*;
+import javax.swing.border.Border;
+import javax.swing.border.EtchedBorder;
+import java.awt.event.ActionListener;
+import java.awt.event.ActionEvent;
+import java.awt.*;
+
+/**
+ * User: geoff
+ * Date: 10/05/2007
+ * Time: 10:03:35
+ * Copyright 2005 Geoffrey G Roy.
+ */
+public class AttributeOrder extends JDialog implements ActionListener {
+
+ private static final I18N i18n = JumpChartPlugIn.I18N;
+ JList attributeList;
+ JButton upButton, downButton, acceptButton, cancelButton;
+ String[] localList;
+ int numItems;
+ ChartDialog parent;
+
+ public AttributeOrder(ChartDialog parent)
+ {
+ super(parent, i18n.get("JumpChart.Order.Order"), true);
+ this.parent = parent;
+ numItems = 0;
+ for (int i=0; i < ChartParams.attributes.length; i++)
+ {
+ if(ChartParams.includeAttribute[i]) numItems++;
+ }
+ //System.out.println("number of selected items = "+numItems);
+
+ localList = new String[numItems];
+ int k = 0;
+ for (int i=0; i < ChartParams.attributes.length; i++)
+ {
+ if(ChartParams.includeAttribute[i])
+ {
+ //String item = ChartParams.attributes[i].name;
+ int order = ChartParams.attributeOrder[i];
+ if(order >= 0) localList[order] = ChartParams.attributes[i].name;
+ else localList[k] = ChartParams.attributes[i].name;
+ k++;
+ }
+ }
+ init();
+ }
+
+ public void init()
+ {
+ GridBagDesigner gb = new GridBagDesigner(this);
+
+ JPanel panel = new JPanel();
+ gb.setPosition(0,0);
+ gb.setInsets(10,10,10,10);
+ gb.setSpan(1,4);
+ attributeList = new JList<>(localList);
+ Border border = new EtchedBorder(EtchedBorder.LOWERED);
+ panel.setBorder(border);
+ panel.setBackground(Color.WHITE);
+ panel.add(attributeList);
+ gb.addComponent(panel);
+
+ upButton = new JButton(i18n.get("JumpChart.Order.MoveUp"));
+ gb.setPosition(1,0);
+ gb.setInsets(10,0,0,10);
+ gb.setFill(GridBagConstraints.HORIZONTAL);
+ gb.addComponent(upButton);
+
+ downButton = new JButton(i18n.get("JumpChart.Order.MoveDown"));
+ gb.setPosition(1,1);
+ gb.setInsets(10,0,0,10);
+ gb.setFill(GridBagConstraints.HORIZONTAL);
+ gb.addComponent(downButton);
+
+ acceptButton = new JButton(i18n.get("JumpChart.Order.Accept"));
+ gb.setPosition(1,2);
+ gb.setInsets(10,0,0,10);
+ gb.setFill(GridBagConstraints.HORIZONTAL);
+ gb.addComponent(acceptButton);
+
+ cancelButton = new JButton(i18n.get("JumpChart.Order.Cancel"));
+ gb.setPosition(1,3);
+ gb.setInsets(10,0,10,10);
+ gb.setFill(GridBagConstraints.HORIZONTAL);
+ gb.setAnchor(GridBagConstraints.SOUTH);
+ gb.addComponent(cancelButton);
+
+ upButton.addActionListener(this);
+ downButton.addActionListener(this);
+ acceptButton.addActionListener(this);
+ cancelButton.addActionListener(this);
+
+ pack();
+ setLocation(parent.getLocation());
+ setVisible(true);
+
+ }
+ public void actionPerformed(ActionEvent ev)
+ {
+ if(ev.getSource() == upButton)
+ {
+ int selectedIndex = attributeList.getSelectedIndex();
+ if(selectedIndex < 1) return;
+ String temp = localList[selectedIndex-1];
+ localList[selectedIndex-1] = localList[selectedIndex];
+ localList[selectedIndex] = temp;
+ attributeList.setListData(localList);
+ attributeList.setSelectedIndex(selectedIndex-1);
+
+
+ }
+ if(ev.getSource() == downButton)
+ {
+ int selectedIndex = attributeList.getSelectedIndex();
+ if(selectedIndex < 0 || selectedIndex > (localList.length-2)) return;
+ String temp = localList[selectedIndex+1];
+ localList[selectedIndex+1] = localList[selectedIndex];
+ localList[selectedIndex] = temp;
+ attributeList.setListData(localList);
+ attributeList.setSelectedIndex(selectedIndex+1);
+ }
+ if(ev.getSource() == acceptButton)
+ {
+ for (int i=0; i < numItems; i++)
+ {
+ String item = localList[i];
+ for (int j=0; j < ChartParams.attributes.length; j++)
+ {
+ if(ChartParams.attributes[j].name.equals(item)) ChartParams.attributeOrder[j] = i;
+ }
+ }
+ dispose();
+ }
+ if(ev.getSource() == cancelButton)
+ {
+ dispose();
+ }
+ }
+
+}
diff --git a/src/main/java/com/cadplan/jump_chart/jump/BarChart.java b/src/main/java/com/cadplan/jump_chart/jump/BarChart.java
new file mode 100644
index 0000000..c85038e
--- /dev/null
+++ b/src/main/java/com/cadplan/jump_chart/jump/BarChart.java
@@ -0,0 +1,334 @@
+/*
+ * The Unified Mapping Platform (JUMP) is an extensible, interactive GUI
+ * for visualizing and manipulating spatial features with geometry and attributes.
+ *
+ * Copyright (C) 2006 Cadplan
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+
+package com.cadplan.jump_chart.jump;
+
+import com.vividsolutions.jump.feature.*;
+import org.locationtech.jts.geom.Coordinate;
+import org.locationtech.jts.geom.Geometry;
+import org.locationtech.jts.geom.GeometryFactory;
+import org.locationtech.jts.geom.LinearRing;
+
+
+/**
+ * User: geoff
+ * Date: 28/04/2007
+ * Time: 16:50:31
+ * Copyright 2007 Geoffrey G Roy.
+ */
+public class BarChart
+{
+ boolean debug = false;
+ ChartAttribute [] attributes;
+ ChartValues [] values;
+ double screenScale;
+ double maxValue;
+ double maxSize;
+ double xoffs, yoffs;
+ double originX, originY;
+
+ public BarChart(ChartAttribute[] attributes, ChartValues[] values, double screenScale)
+ {
+ this.attributes = attributes;
+ this.values = values;
+ this.screenScale = screenScale;
+ xoffs = ChartParams.originX*screenScale;
+ yoffs = ChartParams.originY*screenScale;
+ }
+
+ public double getMaxValue()
+ {
+ return maxValue;
+ }
+ public double getMaxSize()
+ {
+ return maxSize;
+ }
+ public void addFeatures(FeatureCollection dataset)
+ {
+
+ double barHeight;
+ double barWidth = 5*screenScale;
+ double height = 60;
+ double dataMax = Double.MIN_VALUE;
+ double x, y;
+ double barHeightRatio;
+ double maxHeight;
+ double dx;
+
+ double[] itemMax = new double[values.length];
+
+ for (int i=0; i < values.length; i++)
+ {
+
+ double[] data = values[i].values;
+ itemMax[i] = Double.MIN_VALUE;
+
+ for (int j=0; j < data.length; j++)
+ {
+ if(data[j] > dataMax) dataMax = data[j];
+ if(data[j] > itemMax[i]) itemMax[i] = data[j];
+ }
+ }
+ maxValue = dataMax;
+
+
+ for(int i=0; i < values.length; i++)
+ {
+ double [] data = values[i].values;
+ String [] ctypes = values[i].types;
+ String nameValue = values[i].name;
+ x = values[i].x;
+ y = values[i].y;
+ originY = y;
+
+ if(ChartParams.autoScale)
+ {
+ maxHeight = height*screenScale;
+ barWidth = 7*screenScale;
+ }
+ else
+ {
+ maxHeight = ChartParams.scaleValue*screenScale;
+ barWidth = ChartParams.barWidth*screenScale;
+ }
+ maxSize = maxHeight;
+ if(ChartParams.uniformSize)
+ {
+ if(itemMax[i] != 0.0) barHeightRatio = maxHeight/itemMax[i];
+ else barHeightRatio = 1.0;
+ }
+ else
+ {
+ if(dataMax != 0.0) barHeightRatio = maxHeight/dataMax;
+ else barHeightRatio = 1.0;
+ }
+ if(Double.isInfinite(barHeightRatio)) barHeightRatio = 1.0;
+ //System.out.println("barHeightRatio="+barHeightRatio);
+ dx = x - data.length*barWidth/2;
+ for (int j=0; j < data.length; j++)
+ {
+ String name = attributes[j].name;
+ Feature feature = buildFeature(j, dx, y, barWidth, data[j]*barHeightRatio, data[j], name, ctypes[j]);
+ dataset.add(feature);
+ dx = dx + barWidth;
+ }
+
+ // -------------------------------------------
+ // build underlabel feature if required
+ //--------------------------------------------
+ //String nameValue = "Missing";
+ if(ChartParams.showUnderLabels)
+ {
+
+ //System.out.println("Adding feature value namevalue="+nameValue);
+ Feature feature = buildLabelFeature(x, y, nameValue);
+ dataset.add(feature);
+ }
+
+ }
+
+
+
+
+ if(ChartParams.localScale && !ChartParams.uniformSize)
+ {
+ for(int i=0; i < values.length; i++)
+ {
+ double [] data = values[i].values;
+
+ x = values[i].x;
+ y = values[i].y;
+ originX = x + data.length*barWidth/2 + barWidth/2 + xoffs;
+ originY = y + yoffs;
+
+ double interval = ChartParams.scaleInterval(maxValue);
+ double scale = maxSize/maxValue;
+ if(ChartParams.localScale) createLocalScale(dataset,originX, originY, interval, scale, itemMax[i]);
+
+ }
+ }
+
+ }
+
+ private Feature buildLabelFeature(double x, double y, String name)
+ {
+ double xpos, ypos;
+ double fontHeight = 10.0 * screenScale;
+ //System.out.println("fontHeight = " + fontHeight);
+ xpos = x;
+ ypos = y - fontHeight;
+
+ FeatureSchema featureSchema = new FeatureSchema();
+
+ featureSchema.addAttribute("Geometry",AttributeType.GEOMETRY);
+ featureSchema.addAttribute("Index", AttributeType.INTEGER);
+ featureSchema.addAttribute("dValue", AttributeType.DOUBLE);
+ featureSchema.addAttribute("iValue", AttributeType.INTEGER);
+ featureSchema.addAttribute(ChartParams.underLabelName, AttributeType.STRING);
+
+ //System.out.println("Label Feature at:"+x+","+y+" name="+name+ " for attribute: " + ChartParams.underLabelName);
+ Feature feature = new BasicFeature(featureSchema);
+
+
+ Geometry geometry = new GeometryFactory().createPoint(new Coordinate(xpos,ypos));
+ feature.setGeometry(geometry);
+ feature.setAttribute("iValue",-1);
+ feature.setAttribute("dValue",-1.0);
+ feature.setAttribute(ChartParams.underLabelName,name);
+
+
+
+ return feature;
+ }
+
+
+ private Feature buildFeature(int index, double x, double y, double width, double height, double value, String name, String ctype)
+ {
+ FeatureSchema featureSchema = new FeatureSchema();
+
+ featureSchema.addAttribute("Geometry", AttributeType.GEOMETRY);
+ featureSchema.addAttribute("iValue", AttributeType.INTEGER);
+ featureSchema.addAttribute("dValue", AttributeType.DOUBLE);
+ featureSchema.addAttribute("Index", AttributeType.INTEGER);
+ featureSchema.addAttribute("Name", AttributeType.STRING);
+
+
+ if(debug) System.out.println("Feature at:"+x+","+y+" value="+value);
+ Coordinate p = new Coordinate(x+xoffs,y+yoffs);
+ Coordinate [] pointArray = new Coordinate[5];
+ pointArray[0] = new Coordinate(x+xoffs,y+yoffs);
+ pointArray[1]= new Coordinate(x+xoffs+width,y+yoffs);
+ pointArray[2] = new Coordinate(x+xoffs+width,y+yoffs+height);
+ pointArray[3] = new Coordinate(x+xoffs,y+yoffs+height);
+ pointArray[4] = new Coordinate(x+xoffs,y+yoffs);
+ for (int i=0; i < pointArray.length; i++)
+ {
+ if(debug) System.out.println("Point "+i+":"+pointArray[i]);
+ }
+
+ LinearRing lr = new GeometryFactory().createLinearRing(pointArray);
+ Geometry geometry = new GeometryFactory().createPolygon(lr, null);
+
+ Feature feature = new BasicFeature(featureSchema);
+
+ if(debug) System.out.println("Geometry: "+geometry);
+ feature.setGeometry(geometry);
+
+ feature.setAttribute("iValue", (int) value);
+ feature.setAttribute("dValue", value);
+ feature.setAttribute("Index", index);
+
+
+ if(ChartParams.showLabels) feature.setAttribute("Name",name);
+ else feature.setAttribute("Name","");
+ return feature;
+ }
+
+ private void createLocalScale(FeatureCollection dataset, double x, double y, double interval, double scale, double maxValue)
+ {
+ //boolean debug = true;
+ FeatureSchema featureSchema = new FeatureSchema();
+ featureSchema.addAttribute("Geometry", AttributeType.GEOMETRY);
+ featureSchema.addAttribute("dValue", AttributeType.DOUBLE);
+ featureSchema.addAttribute("iValue", AttributeType.INTEGER);
+ featureSchema.addAttribute("Index", AttributeType.INTEGER);
+ featureSchema.addAttribute("Name", AttributeType.STRING);
+
+ double width = 3*screenScale;
+ double yp = y+ 5*interval*scale;
+
+ //Coordinate [] points = new Coordinate[2];
+ //points[0] = new Coordinate(x,y);
+ //points[1] = new Coordinate(x,y+ 5*interval*scale);
+
+ //Geometry geometry = new GeometryFactory().createLineString(points);
+
+ //if(debug) System.out.println("Line Geometry: "+geometry);
+ //Feature feature = new BasicFeature(featureSchema);
+
+
+ //feature.setGeometry(geometry);
+ //feature.setAttribute("iValue",-1);
+ //feature.setAttribute("dValue",-1.0);
+ //feature.setAttribute("Name","");
+ //dataset.add(feature);
+ for(int i=1; i <=5 ; i++)
+ {
+ Coordinate [] linePoints = new Coordinate[2];
+ linePoints[0] = new Coordinate(x,y+interval*scale*i);
+ linePoints[1] = new Coordinate(x-width, y+interval*scale*i);
+
+ Geometry linegeometry = new GeometryFactory().createLineString(linePoints);
+
+ Feature linefeature = new BasicFeature(featureSchema);
+
+ if(debug) System.out.println("i="+i+" Bar Geometry: "+linegeometry);
+ linefeature.setGeometry(linegeometry);
+ linefeature.setAttribute("dValue",-1.0);
+ linefeature.setAttribute("iValue",-1);
+ linefeature.setAttribute("Index",-1);
+
+ if(interval*i < maxValue && i < 5)
+ {
+ linefeature.setAttribute("Name","");
+ dataset.add(linefeature);
+ }
+ else
+ {
+ linefeature.setAttribute("Name",formatValue(interval,i));
+ dataset.add(linefeature);
+
+ Coordinate [] points = new Coordinate[2];
+ points[0] = new Coordinate(x,y);
+ points[1] = new Coordinate(x,y+ i*interval*scale);
+ Geometry geometry = new GeometryFactory().createLineString(points);
+ if(debug) System.out.println("Line Geometry: "+geometry);
+ Feature feature = new BasicFeature(featureSchema);
+ feature.setGeometry(geometry);
+ feature.setAttribute("iValue",-1);
+ feature.setAttribute("dValue",-1.0);
+ feature.setAttribute("Name","");
+ dataset.add(feature);
+ break;
+ }
+
+ //if(i < 5) linefeature.setAttribute("Name","");
+ //else linefeature.setAttribute("Name",formatValue(interval,i));
+ //dataset.add(linefeature);
+
+
+ }
+
+
+
+ }
+
+ private String formatValue(double interval, int step)
+ {
+ return NumberFormatter.format(interval*step);
+ //if(interval < 1.0) return String.valueOf(interval*step);
+ //return String.valueOf((int)(interval*step));
+ }
+
+}
diff --git a/src/main/java/com/cadplan/jump_chart/jump/Chart.java b/src/main/java/com/cadplan/jump_chart/jump/Chart.java
new file mode 100644
index 0000000..fc5c84e
--- /dev/null
+++ b/src/main/java/com/cadplan/jump_chart/jump/Chart.java
@@ -0,0 +1,559 @@
+/*
+ * The Unified Mapping Platform (JUMP) is an extensible, interactive GUI
+ * for visualizing and manipulating spatial features with geometry and attributes.
+ *
+ * Copyright (C) 2006 Cadplan
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+package com.cadplan.jump_chart.jump;
+
+import java.awt.Color;
+import java.util.HashMap;
+import java.util.Map;
+
+import com.vividsolutions.jump.I18N;
+import com.vividsolutions.jump.feature.AttributeType;
+import com.vividsolutions.jump.feature.BasicFeature;
+import com.vividsolutions.jump.feature.Feature;
+import com.vividsolutions.jump.feature.FeatureCollection;
+import com.vividsolutions.jump.feature.FeatureDataset;
+import com.vividsolutions.jump.feature.FeatureSchema;
+import com.vividsolutions.jump.workbench.model.Category;
+import com.vividsolutions.jump.workbench.model.Layer;
+import com.vividsolutions.jump.workbench.plugin.PlugInContext;
+import com.vividsolutions.jump.workbench.ui.renderer.style.BasicStyle;
+import com.vividsolutions.jump.workbench.ui.renderer.style.ColorThemingStyle;
+import com.vividsolutions.jump.workbench.ui.renderer.style.LabelStyle;
+import org.locationtech.jts.geom.Coordinate;
+import org.locationtech.jts.geom.Geometry;
+import org.locationtech.jts.geom.GeometryFactory;
+import org.locationtech.jts.geom.LinearRing;
+
+/**
+ * User: geoff Date: 28/04/2007 Time: 10:04:38 Copyright 2007 Geoffrey G Roy.
+ */
+public class Chart {
+ boolean debug = false;
+ PlugInContext context;
+ String categoryName = "Jump Charts";
+ ChartData chartData;
+ ChartValues[] chartValues;
+ ChartAttribute[] chartAttributes;
+ FeatureDataset dataset;
+ double screenScale;
+ I18N i18n;
+
+ public Chart(PlugInContext context, I18N i18n) {
+ this.context = context;
+ this.i18n = i18n;
+ ChartParams.cancelled = false;
+ chartData = new ChartData(context, i18n);
+
+ if (!ChartParams.cancelled) {
+
+ getData();
+
+ for (final ChartValues chartValue : chartValues) {
+ // System.out.println("Att i="+i+ " value="+
+ // chartValues[i].toString());
+ }
+
+ createContext();
+ createFeatures();
+ final Layer layer = context
+ .addLayer(categoryName, "Chart", dataset);
+ final ColorThemingStyle colorThemingStyle = ColorThemingStyle
+ .get(layer);
+ final String actualName = layer.getName();
+ final BasicStyle layerStyle = layer.getBasicStyle();
+ layerStyle.setAlpha(255);
+
+ final LabelStyle newLabelStyle = layer.getLabelStyle();
+ newLabelStyle.setEnabled(true);
+ newLabelStyle.setAttribute("Name");
+ newLabelStyle.setEnabled(true); // to show labels in legends
+
+ newLabelStyle.setVerticalAlignment(LabelStyle.ON_LINE);
+
+ // System.out.println("Vert Align:"+newLabelStyle.verticalAlignment);
+ layer.removeStyle(layer.getLabelStyle());
+ layer.addStyle(newLabelStyle);
+
+ final Map