Skip to content

Commit

Permalink
Fixing chat's scatter added
Browse files Browse the repository at this point in the history
  • Loading branch information
eakurnikov committed Sep 11, 2017
1 parent 632bc60 commit 0a93c40
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 17 deletions.
1 change: 1 addition & 0 deletions .idea/modules/CapStruct.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/modules/CapStruct_main.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/modules/CapStruct_test.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 12 additions & 15 deletions src/main/java/com/private_void/app/MainController.java
Original file line number Diff line number Diff line change
Expand Up @@ -205,26 +205,23 @@ private void showResult(Flux flux, Surface capillar) {

//TODO как-то разукрашивать точки в зависимости от их интенсивности. Тогда детектор как счетчик интенсивности со своими ячейками ваще не нужен, нужна будет тупо его плоскость
chart.getData().addAll(series);

chart.getXAxis().autosize();
chart.getYAxis().autosize();

// if (xAxis.getUpperBound() > yAxis.getUpperBound()) {
// yAxis.setUpperBound(xAxis.getUpperBound());
// } else {
// xAxis.setUpperBound(yAxis.getUpperBound());
// }
//
// if (xAxis.getLowerBound() < yAxis.getLowerBound()) {
// yAxis.setLowerBound(xAxis.getLowerBound());
// } else {
// xAxis.setLowerBound(yAxis.getLowerBound());
// }
setChartScale(flux.getUpperBound(), flux.getLowerBound());

intensityOn.setText(String.valueOf(capillar.getDetectedParticlesAmount()));
intensityAbsorbed.setText(String.valueOf(capillar.getNotDetectedParticlesAmount()));
intensityOut.setText(String.valueOf(capillar.getOutOfCapillarParticlesAmount()));

successLabel.setVisible(true);
}

private void setChartScale(double upperBound, double lowerBound) {
xAxis.setAutoRanging(false);
yAxis.setAutoRanging(false);

xAxis.setUpperBound(upperBound);
yAxis.setUpperBound(upperBound);

xAxis.setLowerBound(lowerBound);
yAxis.setLowerBound(lowerBound);
}
}
1 change: 1 addition & 0 deletions src/main/java/com/private_void/core/Detector.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public Flux detect(Flux flux) {
}

flux.setParticles(detectedParticles);
flux.computeScatter(width);
return flux;
}

Expand Down
33 changes: 33 additions & 0 deletions src/main/java/com/private_void/core/Flux.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ public abstract class Flux {
protected Vector3D fluxAxis;
protected int particlesAmount;
protected float minIntensity;
protected double upperBound;
protected double lowerBound;
protected ArrayList<Particle> particles;

protected Flux(final Point3D fluxCoordinate, final Vector3D fluxAxis, int particlesAmount, float minIntensity) {
Expand Down Expand Up @@ -37,6 +39,14 @@ public void setMinIntensity(float minIntensity) {
this.minIntensity = minIntensity;
}

public double getUpperBound() {
return upperBound;
}

public double getLowerBound() {
return lowerBound;
}

protected void checkParameters() {
if (fluxAxis.getX() == 0.0f) {
fluxAxis.setX(0.000001f);
Expand All @@ -48,4 +58,27 @@ protected void checkParameters() {
fluxAxis.setZ(0.000001f);
}
}

public void computeScatter(float maxWidth) {
for (Particle particle : particles) {
if (particle.getCoordinate().getX() > upperBound) {
upperBound = particle.getCoordinate().getX();
}
if (particle.getCoordinate().getY() > upperBound) {
upperBound = particle.getCoordinate().getY();
}
if (particle.getCoordinate().getX() < lowerBound) {
lowerBound = particle.getCoordinate().getX();
}
if (particle.getCoordinate().getY() < lowerBound) {
lowerBound = particle.getCoordinate().getY();
}
}
if (upperBound > maxWidth) {
upperBound = maxWidth;
}
if (lowerBound < -maxWidth) {
lowerBound = -maxWidth;
}
}
}
1 change: 1 addition & 0 deletions src/main/java/com/private_void/core/RotatedDetector.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public Flux detect(Flux flux) {
ex.printStackTrace();
}
flux.setParticles(detectedParticles);
flux.computeScatter(width);
return flux;
}
}

0 comments on commit 0a93c40

Please sign in to comment.