Initial
This commit is contained in:
@@ -630,17 +630,17 @@ public class LinePlot extends ch.psi.plot.LinePlotBase {
|
||||
|
||||
void addSwingMenuItem(final ObservableList<MenuItem> menu, final JMenuItem item) {
|
||||
if (item instanceof JMenu) {
|
||||
Menu menu_fx = new Menu(item.getText());
|
||||
Menu menuFx = new Menu(item.getText());
|
||||
for (Component menuItem : ((JMenu) item).getMenuComponents()) {
|
||||
if (menuItem instanceof JMenu) {
|
||||
addSwingMenuItem(menu_fx.getItems(), ((JMenu) menuItem));
|
||||
addSwingMenuItem(menuFx.getItems(), ((JMenu) menuItem));
|
||||
} else if (menuItem instanceof JPopupMenu.Separator) {
|
||||
menu_fx.getItems().add(new SeparatorMenuItem());
|
||||
menuFx.getItems().add(new SeparatorMenuItem());
|
||||
} else if (menuItem instanceof JMenuItem) {
|
||||
addSwingMenuItem(menu_fx.getItems(), ((JMenuItem) menuItem));
|
||||
addSwingMenuItem(menuFx.getItems(), ((JMenuItem) menuItem));
|
||||
}
|
||||
}
|
||||
menu.add(menu_fx);
|
||||
menu.add(menuFx);
|
||||
} else if (item instanceof JMenuItem) {
|
||||
MenuItem itemFX = new MenuItem(item.getText());
|
||||
itemFX.setOnAction(new EventHandler<ActionEvent>() {
|
||||
|
||||
@@ -222,10 +222,10 @@ public class LinePlot extends LinePlotBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onAxisRangeChanged(AxisId axis_id) {
|
||||
protected void onAxisRangeChanged(AxisId axisId) {
|
||||
ValueAxis axis = null;
|
||||
|
||||
switch (axis_id) {
|
||||
switch (axisId) {
|
||||
case X:
|
||||
axis = chart.getXYPlot().getDomainAxis();
|
||||
break;
|
||||
@@ -235,10 +235,10 @@ public class LinePlot extends LinePlotBase {
|
||||
default:
|
||||
return;
|
||||
}
|
||||
if (getAxis(axis_id).isAutoRange()) {
|
||||
if (getAxis(axisId).isAutoRange()) {
|
||||
axis.setAutoRange(true);
|
||||
} else {
|
||||
axis.setRange(new Range(getAxis(axis_id).getMin(), getAxis(axis_id).getMax()), true, true);
|
||||
axis.setRange(new Range(getAxis(axisId).getMin(), getAxis(axisId).getMax()), true, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -119,10 +119,10 @@ public class MatrixPlot extends MatrixPlotBase {
|
||||
|
||||
|
||||
@Override
|
||||
protected void onAxisRangeChanged(AxisId axis_id) {
|
||||
protected void onAxisRangeChanged(AxisId axisId) {
|
||||
// The axis min and max values need to be half a bin larger. Otherwise the outer pixels
|
||||
// will not be plotted correctly (half of the pixel is missing)
|
||||
if (axis_id == AxisId.X) {
|
||||
if (axisId == AxisId.X) {
|
||||
if (getAxis(AxisId.X).isAutoRange()) {
|
||||
xMin = series.getMinX() - 0.5 * series.getBinWidthX();
|
||||
xMax = series.getMaxX() + 0.5 * series.getBinWidthX();
|
||||
@@ -133,7 +133,7 @@ public class MatrixPlot extends MatrixPlotBase {
|
||||
xAxis.setLowerBound(xMin);
|
||||
xAxis.setUpperBound(xMax);
|
||||
}
|
||||
if (axis_id == AxisId.Y) {
|
||||
if (axisId == AxisId.Y) {
|
||||
if (getAxis(AxisId.Y).isAutoRange()) {
|
||||
yMin = series.getMinY() - 0.5 * series.getBinWidthY();
|
||||
yMax = series.getMaxY() + 0.5 * series.getBinWidthY();
|
||||
|
||||
@@ -203,9 +203,9 @@ public class LinePlot extends LinePlotBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onAxisRangeChanged(AxisId axis_id) {
|
||||
protected void onAxisRangeChanged(AxisId axisId) {
|
||||
JLAxis axis = null;
|
||||
switch (axis_id) {
|
||||
switch (axisId) {
|
||||
case X:
|
||||
axis = plot.getXAxis();
|
||||
break;
|
||||
@@ -215,9 +215,9 @@ public class LinePlot extends LinePlotBase {
|
||||
default:
|
||||
return;
|
||||
}
|
||||
axis.setAutoScale(getAxis(axis_id).isAutoRange());
|
||||
axis.setMinimum(getAxis(axis_id).getMin());
|
||||
axis.setMaximum(getAxis(axis_id).getMax());
|
||||
axis.setAutoScale(getAxis(axisId).isAutoRange());
|
||||
axis.setMinimum(getAxis(axisId).getMin());
|
||||
axis.setMaximum(getAxis(axisId).getMax());
|
||||
update(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -186,7 +186,7 @@ public class MatrixPlot extends MatrixPlotBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onAxisRangeChanged(AxisId axis_id) {
|
||||
protected void onAxisRangeChanged(AxisId axisId) {
|
||||
if (series != null) {
|
||||
updateGraph(true);
|
||||
}
|
||||
@@ -990,19 +990,19 @@ public class MatrixPlot extends MatrixPlotBase {
|
||||
}
|
||||
boolean changed = false;
|
||||
boolean hasContour=(getContour() != Contour.NONE) ;
|
||||
boolean auto_range = getAxis(AxisId.X).isAutoRange() && getAxis(AxisId.Y).isAutoRange() && getAxis(AxisId.Z).isAutoRange();
|
||||
boolean force_series_range = getAxis(AxisId.X).isAutoRange() && getAxis(AxisId.Y).isAutoRange() && (!getHideEmptyRows());
|
||||
boolean manual_bounds= (!auto_range) || hasContour || force_series_range;
|
||||
boolean autoRange = getAxis(AxisId.X).isAutoRange() && getAxis(AxisId.Y).isAutoRange() && getAxis(AxisId.Z).isAutoRange();
|
||||
boolean forceSeriesRange = getAxis(AxisId.X).isAutoRange() && getAxis(AxisId.Y).isAutoRange() && (!getHideEmptyRows());
|
||||
boolean manualBounds= (!autoRange) || hasContour || forceSeriesRange;
|
||||
|
||||
//If manual bounds
|
||||
if ( manual_bounds) {
|
||||
if ( manualBounds) {
|
||||
//Deferring setting bounds untiul the panel is displayed
|
||||
if (isShowing() && (chart != null)) {
|
||||
if (chart.getView().getBoundsMode() != ViewBoundMode.MANUAL) {
|
||||
changed = true;
|
||||
}
|
||||
BoundingBox3d bounds = chart.getView().getBounds();
|
||||
if (hasContour || force_series_range){
|
||||
if (hasContour || forceSeriesRange){
|
||||
//TODO: Auto-range will not plot points=NaN, and bounds can be smaller. It will break the contour plot.
|
||||
//Cant I find a way to plot only the visible contour instead of foercing the full range?
|
||||
if (bounds.getXmin() != rangeX.getMin()) {
|
||||
|
||||
@@ -4,12 +4,11 @@
|
||||
package ch.psi.plot.utils;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
/**
|
||||
@@ -17,24 +16,12 @@ import javax.imageio.ImageIO;
|
||||
*/
|
||||
public class IO {
|
||||
|
||||
public static void writeArrayToFile(String filename, byte arr[]) throws IOException {
|
||||
|
||||
OutputStream fout = null;
|
||||
try {
|
||||
fout = new BufferedOutputStream(new FileOutputStream(filename, false));
|
||||
if (arr != null) {
|
||||
new PrintStream(fout).write(arr, 0, arr.length);
|
||||
}
|
||||
fout.flush();
|
||||
} finally {
|
||||
if (fout != null) {
|
||||
fout.close();
|
||||
}
|
||||
}
|
||||
public static void writeArrayToFile(String filename, byte[] arr) throws IOException {
|
||||
Files.write(Paths.get(filename),arr);
|
||||
}
|
||||
|
||||
public static void writeStringToFile(String filename, String str) throws IOException {
|
||||
writeArrayToFile(filename, str.getBytes("UTF-8"));
|
||||
writeArrayToFile(filename, str.getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
public static void writeImageToFile(BufferedImage image, String filename, String format) throws IOException {
|
||||
|
||||
Reference in New Issue
Block a user