Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update fork #2

Merged
merged 8 commits into from
Aug 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions doc/JTS_Version_History.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ Distributions for older JTS versions can be obtained at the

* Fix `IndexedPointInAreaLocator` thread-safety (#572)
* Fix `WKTReader` to handle MultiPoints containing `EMPTY` (#575)
* Fix API compile regression by removing deprecation on geometry `reverse` methods (#582)

## JTS TestBuilder

### Functionality Improvements

* Add per-Layer palette control for Strokes and Fills

## JTS TestRunner

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,7 @@ public class AppStrings {

public static final String TIP_STYLE_VERTEX_LABEL_ENABLE = "Show vertex labels";

public static final String TIP_STYLE_PALETTE = "<html>Palette type used for Lines or Fills.<br>Layer color determines base hue and lightness</html> ";


}
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,12 @@
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ButtonGroup;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JRadioButtonMenuItem;

import org.locationtech.jtstest.testbuilder.model.DisplayParameters;

public class JTSTestBuilderMenuBar
{
JMenuBar jMenuBar1 = new JMenuBar();
Expand Down Expand Up @@ -129,31 +126,6 @@ public void actionPerformed(ActionEvent e) {
}
});

final JMenuItem basicFillMenuItem = menuItemRadio("Basic Fill", true,
new ActionListener() {
public void actionPerformed(ActionEvent e) {
JTSTestBuilder.controller().setFillType(DisplayParameters.FILL_BASIC);
}
});
final JMenuItem varyFillMenuItem = menuItemRadio("Varying Fill", false,
new ActionListener() {
public void actionPerformed(ActionEvent e) {
JTSTestBuilder.controller().setFillType(DisplayParameters.FILL_VARY);
}
});
final JMenuItem rainbowFillMenuItem = menuItemRadio("Rainbow Fill", false,
new ActionListener() {
public void actionPerformed(ActionEvent e) {
JTSTestBuilder.controller().setFillType(DisplayParameters.FILL_RAINBOW);
}
});
final JMenuItem rainbowRandomFillMenuItem = menuItemRadio("Random Rainbow Fill", false,
new ActionListener() {
public void actionPerformed(ActionEvent e) {
JTSTestBuilder.controller().setFillType(DisplayParameters.FILL_RAINBOW_RANDOM);
}
});

menuLoadXmlTestFolder.setText("Open XML Folder(s)...");
menuLoadXmlTestFolder.addActionListener(
new java.awt.event.ActionListener() {
Expand Down Expand Up @@ -184,13 +156,6 @@ public void actionPerformed(ActionEvent e) {
//jMenuOptions.setText("Options");
//jMenuTools.setText("Tools");

ButtonGroup fillGroup = new ButtonGroup();
fillGroup.add(basicFillMenuItem);
fillGroup.add(varyFillMenuItem);
fillGroup.add(rainbowFillMenuItem);
fillGroup.add(rainbowRandomFillMenuItem);
basicFillMenuItem.setSelected(true);

jMenuFile.add(menuLoadXmlTestFile);
jMenuFile.add(menuLoadXmlTestFolder);
jMenuFile.add(saveAsXmlMenuItem);
Expand All @@ -206,12 +171,6 @@ public void actionPerformed(ActionEvent e) {
//==========================
jMenuView.setText("View");

jMenuView.add(basicFillMenuItem);
jMenuView.add(varyFillMenuItem);
jMenuView.add(rainbowFillMenuItem);
jMenuView.add(rainbowRandomFillMenuItem);

jMenuView.addSeparator();
jMenuView.add(menuViewText);
jMenuView.add(menuViewGeometry);
//==========================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ public void actionPerformed(ActionEvent e) {
//add(lyrStylePanel, BorderLayout.CENTER);

//tabFunctions.setBackground(jTabbedPane1.getBackground());
tabPane.add(lyrStylePanel, LBL_LAYER);
JScrollPane scrollPane = new JScrollPane();
scrollPane.getViewport().add(lyrStylePanel, null);
tabPane.add(scrollPane, LBL_LAYER);
tabPane.add(viewStylePanel, LBL_VIEW);
add(tabPane, BorderLayout.CENTER);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.AbstractButton;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
Expand All @@ -44,6 +44,7 @@
import org.locationtech.jtstest.testbuilder.ui.SwingUtil;
import org.locationtech.jtstest.testbuilder.ui.style.BasicStyle;
import org.locationtech.jtstest.testbuilder.ui.style.LayerStyle;
import org.locationtech.jtstest.testbuilder.ui.style.Palette;

public class LayerStylePanel extends JPanel {
private Layer layer;
Expand Down Expand Up @@ -78,6 +79,7 @@ public class LayerStylePanel extends JPanel {
private JSpinner spinnerOffsetSize;
private SpinnerNumberModel offsetSizeModel;
private JCheckBox cbEndpoint;
private JComboBox comboPalette;


public LayerStylePanel() {
Expand Down Expand Up @@ -112,6 +114,7 @@ public void setLayer(Layer layer, boolean isModifiable) {
cbOrient.setSelected(layer.getLayerStyle().isOrientations());
cbStructure.setSelected(layer.getLayerStyle().isOrientations());
lineWidthModel.setValue(geomStyle().getStrokeWidth());
setPaletteType(comboPalette, layer.getLayerStyle().getFillType());
updateStyleControls();
}

Expand Down Expand Up @@ -265,7 +268,7 @@ public void colorChanged(Color clr) {
}
}
);
JButton btnVertexSynch = SwingUtil.createButton("^", "Synch Vertex Color", new ActionListener() {
JButton btnVertexSynch = createSynchButton("^", "Synch Vertex Color", new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
if (layer == null) return;
Color clr = ColorControl.getColor(btnLineColor);
Expand Down Expand Up @@ -303,7 +306,7 @@ public void stateChanged(ChangeEvent e) {
}
}
});
addRow("Line", cbStroked, btnLineColor, btnVertexSynch, spinnerLineWidth, sliderLineAlpha);
addRow("Line", cbStroked, btnLineColor, btnVertexSynch, sliderLineAlpha, spinnerLineWidth);

//=============================================
cbDashed = new JCheckBox();
Expand Down Expand Up @@ -412,7 +415,7 @@ public void colorChanged(Color clr) {
}
}
);
JButton btnLineSynch = SwingUtil.createButton("^", "Synch Line Color", new ActionListener() {
JButton btnLineSynch = createSynchButton("^", "Synch Line Color", new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
Color clr = lineColorFromFill( ColorControl.getColor(btnFillColor));
geomStyle().setLineColor(clr );
Expand All @@ -425,6 +428,21 @@ public void actionPerformed(ActionEvent arg0) {

//=============================================

comboPalette = new JComboBox(paletteNames);
comboPalette.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JComboBox cb = (JComboBox)e.getSource();
int fillType = getPaletteType(cb);
layer.getLayerStyle().setFillType(fillType);
JTSTestBuilder.controller().geometryViewChanged();
}
});
comboPalette.setToolTipText(AppStrings.TIP_STYLE_PALETTE);
addRow("Palette", comboPalette);

//=============================================


cbLabel = new JCheckBox();
//cbLabel.setToolTipText(AppStrings.TIP_STYLE_VERTEX_ENABLE);
cbLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
Expand Down Expand Up @@ -468,13 +486,47 @@ public void stateChanged(ChangeEvent e) {
return containerPanel;
}

static String[] paletteNames = { "Basic", "Varying", "Rainbow", "Rainbow Random" };

private static int getPaletteType(JComboBox comboPal) {
String palName = (String)comboPal.getSelectedItem();

int paletteType = Palette.TYPE_BASIC;
if (palName.equalsIgnoreCase(paletteNames[1])) paletteType = Palette.TYPE_VARY;
if (palName.equalsIgnoreCase(paletteNames[2])) paletteType = Palette.TYPE_RAINBOW;
if (palName.equalsIgnoreCase(paletteNames[3])) paletteType = Palette.TYPE_RAINBOW_RANDOM;
return paletteType;
}

private static void setPaletteType(JComboBox comboPal, int paletteType) {
int index = 0;
if (paletteType == Palette.TYPE_VARY) index = 1;
if (paletteType == Palette.TYPE_RAINBOW) index = 2;
if (paletteType == Palette.TYPE_RAINBOW_RANDOM) index = 3;
comboPal.setSelectedIndex(index);
}

protected static Color lineColorFromFill(Color clr) {
return ColorUtil.saturate(clr, 1);
//return clr.darker();
}

private JButton createSynchButton(String lbl, String tip, ActionListener actionListener) {
JButton btn = SwingUtil.createButton(lbl, tip, actionListener);
btn.setMargin(new Insets(0, 0, 0, 0));
Dimension dim = new Dimension(16, 20);
btn.setMinimumSize(dim);
btn.setPreferredSize(dim);
btn.setMaximumSize(dim);
return btn;
}

private JSlider createOpacitySlider(ChangeListener changeListener) {
JSlider slide = new JSlider(JSlider.HORIZONTAL, 0, 255, 150);
Dimension dim = new Dimension(80, 20);
slide.setMinimumSize(dim);
slide.setPreferredSize(dim);
slide.setMaximumSize(dim);
slide.addChangeListener(changeListener);
slide.setMajorTickSpacing(32);
slide.setPaintTicks(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,6 @@ public GeometryEditModel geomEditModel() {
return JTSTestBuilder.model().getGeometryEditModel();
}

public void setFillType(int fillType) {
DisplayParameters.setFillType(fillType);
geometryViewChanged();
}

public void geometryViewChanged()
{
getGeometryEditPanel().updateView();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,6 @@ public static double getTopologyStretchSize() {

public static int MAX_DISPLAY_POINTS = 2000;

public static final int FILL_BASIC = 1;
public static final int FILL_VARY = 2;
public static final int FILL_RAINBOW = 3;
public static final int FILL_RAINBOW_RANDOM = 4;

private static int fillType = FILL_BASIC;

public static int fillType() {
return fillType;
}

public static void setFillType(int type) {
fillType = type;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,31 @@

package org.locationtech.jtstest.testbuilder.model;

import java.io.*;
import java.util.*;

import org.locationtech.jts.geom.*;
import org.locationtech.jts.io.*;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;

import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.geom.GeometryFactory;
import org.locationtech.jts.geom.PrecisionModel;
import org.locationtech.jts.io.ParseException;
import org.locationtech.jts.io.WKTReader;
import org.locationtech.jts.io.WKTWriter;
import org.locationtech.jts.math.MathUtil;
import org.locationtech.jts.util.Assert;
import org.locationtech.jtstest.test.TestCaseList;
import org.locationtech.jtstest.test.Testable;
import org.locationtech.jtstest.testbuilder.AppConstants;
import org.locationtech.jtstest.testbuilder.GeometryDepiction;
import org.locationtech.jtstest.testbuilder.ui.*;
import org.locationtech.jtstest.testbuilder.ui.SwingUtil;
import org.locationtech.jtstest.testbuilder.ui.style.BasicStyle;
import org.locationtech.jtstest.testrunner.TestReader;
import org.locationtech.jtstest.testrunner.TestRun;
import org.locationtech.jtstest.util.*;
import org.locationtech.jtstest.util.ExceptionFormatter;
import org.locationtech.jtstest.util.StringUtil;
import org.locationtech.jtstest.util.io.IOUtil;
import org.locationtech.jtstest.util.io.MultiFormatReader;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ public static float getHue(Color clr) {
return hsb[0];
}

public static float getSaturation(Color clr) {
float[] hsb = Color.RGBtoHSB(clr.getRed(), clr.getGreen(), clr.getBlue(), null);
return hsb[1];
}

public static float getBrightness(Color clr) {
float[] hsb = Color.RGBtoHSB(clr.getRed(), clr.getGreen(), clr.getBlue(), null);
return hsb[2];
}

public static Color setAlpha(Color clr, int alpha) {
return new Color(clr.getRed(), clr.getGreen(), clr.getBlue(), alpha);
}
Expand Down
Loading