new plotter
This commit is contained in:
@@ -26,11 +26,17 @@ public interface CalculatorPlotter {
|
||||
boolean removeFunction(@NotNull PlotFunction plotFunction);
|
||||
boolean removeFunction(@NotNull XyFunction xyFunction);
|
||||
|
||||
void pin(@NotNull PlotFunction plotFunction);
|
||||
void unpin(@NotNull PlotFunction plotFunction);
|
||||
@NotNull
|
||||
PlotFunction pin(@NotNull PlotFunction plotFunction);
|
||||
|
||||
void show(@NotNull PlotFunction plotFunction);
|
||||
void hide(@NotNull PlotFunction plotFunction);
|
||||
@NotNull
|
||||
PlotFunction unpin(@NotNull PlotFunction plotFunction);
|
||||
|
||||
@NotNull
|
||||
PlotFunction show(@NotNull PlotFunction plotFunction);
|
||||
|
||||
@NotNull
|
||||
PlotFunction hide(@NotNull PlotFunction plotFunction);
|
||||
|
||||
void clearAllFunctions();
|
||||
|
||||
@@ -42,7 +48,9 @@ public interface CalculatorPlotter {
|
||||
|
||||
void plot();
|
||||
|
||||
boolean isPlotPossible(@NotNull Generic expression);
|
||||
boolean is2dPlotPossible();
|
||||
|
||||
boolean isPlotPossibleFor(@NotNull Generic expression);
|
||||
|
||||
void setPlot3d(boolean plot3d);
|
||||
|
||||
|
@@ -31,6 +31,8 @@ public class CalculatorPlotterImpl implements CalculatorPlotter {
|
||||
|
||||
private boolean plotImag = false;
|
||||
|
||||
private int arity = 0;
|
||||
|
||||
@NotNull
|
||||
private GraphLineColor realLineColor;
|
||||
|
||||
@@ -134,6 +136,14 @@ public class CalculatorPlotterImpl implements CalculatorPlotter {
|
||||
|
||||
@Override
|
||||
public boolean updateFunction(@NotNull PlotFunction newFunction) {
|
||||
boolean changed = updateFunction0(newFunction);
|
||||
if (changed) {
|
||||
firePlotDataChangedEvent();
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
public boolean updateFunction0(@NotNull PlotFunction newFunction) {
|
||||
boolean changed = false;
|
||||
|
||||
synchronized (functions) {
|
||||
@@ -156,26 +166,40 @@ public class CalculatorPlotterImpl implements CalculatorPlotter {
|
||||
return removeFunction(new PlotFunction(xyFunction));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public void pin(@NotNull PlotFunction plotFunction) {
|
||||
updateFunction(PlotFunction.pin(plotFunction));
|
||||
public PlotFunction pin(@NotNull PlotFunction plotFunction) {
|
||||
final PlotFunction newFunction = PlotFunction.pin(plotFunction);
|
||||
updateFunction0(newFunction);
|
||||
return newFunction;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public void unpin(@NotNull PlotFunction plotFunction) {
|
||||
updateFunction(PlotFunction.unpin(plotFunction));
|
||||
public PlotFunction unpin(@NotNull PlotFunction plotFunction) {
|
||||
final PlotFunction newFunction = PlotFunction.unpin(plotFunction);
|
||||
updateFunction0(newFunction);
|
||||
return newFunction;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public void show(@NotNull PlotFunction plotFunction) {
|
||||
updateFunction(PlotFunction.visible(plotFunction));
|
||||
firePlotDataChangedEvent();
|
||||
public PlotFunction show(@NotNull PlotFunction plotFunction) {
|
||||
final PlotFunction newFunction = PlotFunction.visible(plotFunction);
|
||||
|
||||
updateFunction(newFunction);
|
||||
|
||||
return newFunction;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public void hide(@NotNull PlotFunction plotFunction) {
|
||||
updateFunction(PlotFunction.invisible(plotFunction));
|
||||
firePlotDataChangedEvent();
|
||||
public PlotFunction hide(@NotNull PlotFunction plotFunction) {
|
||||
final PlotFunction newFunction = PlotFunction.invisible(plotFunction);
|
||||
|
||||
updateFunction(newFunction);
|
||||
|
||||
return newFunction;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -203,6 +227,8 @@ public class CalculatorPlotterImpl implements CalculatorPlotter {
|
||||
plot3d = false;
|
||||
}
|
||||
|
||||
arity = maxArity;
|
||||
|
||||
firePlotDataChangedEvent();
|
||||
}
|
||||
|
||||
@@ -233,7 +259,12 @@ public class CalculatorPlotterImpl implements CalculatorPlotter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlotPossible(@NotNull Generic expression) {
|
||||
public boolean is2dPlotPossible() {
|
||||
return arity < 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlotPossibleFor(@NotNull Generic expression) {
|
||||
boolean result = false;
|
||||
|
||||
int size = CalculatorUtils.getNotSystemConstants(expression).size();
|
||||
|
@@ -42,27 +42,36 @@ public class PlotFunction {
|
||||
}
|
||||
|
||||
public static PlotFunction pin(@NotNull PlotFunction that) {
|
||||
return togglePinned(that, true);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static PlotFunction togglePinned(@NotNull PlotFunction that, boolean pinned) {
|
||||
final PlotFunction copy = that.copy();
|
||||
copy.pinned = true;
|
||||
copy.pinned = pinned;
|
||||
return copy;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static PlotFunction unpin(@NotNull PlotFunction that) {
|
||||
final PlotFunction copy = that.copy();
|
||||
copy.pinned = false;
|
||||
return copy;
|
||||
return togglePinned(that, false);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static PlotFunction visible(@NotNull PlotFunction that) {
|
||||
return toggleVisible(that, true);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static PlotFunction toggleVisible(@NotNull PlotFunction that, boolean visible) {
|
||||
final PlotFunction copy = that.copy();
|
||||
copy.visible = true;
|
||||
copy.visible = visible;
|
||||
return copy;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static PlotFunction invisible(@NotNull PlotFunction that) {
|
||||
final PlotFunction copy = that.copy();
|
||||
copy.visible = false;
|
||||
return copy;
|
||||
return toggleVisible(that, false);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
Reference in New Issue
Block a user