update VisibleCell

This commit is contained in:
nisihara1 2017-08-11 14:37:20 +09:00
parent 3c78336382
commit 50b07b185e
3 changed files with 53 additions and 4 deletions

View File

@ -87,6 +87,7 @@ public class VisibleAtom extends Visible<Atom> implements AtomEventListener, Ato
this.updateXYZOfSphere();
this.updateColorOfSphere();
this.updateDrawMode();
this.getChildren().add(this.atomSphere);
}

View File

@ -86,6 +86,7 @@ public class VisibleBond extends Visible<Bond> implements BondEventListener, Ato
this.updateRadiusOfCylinder();
this.updateXYZOfCylinder();
this.updateColorOfCylinder();
this.getChildren().add(this.bondCylinder1);
this.getChildren().add(this.bondCylinder2);
}
@ -362,15 +363,15 @@ public class VisibleBond extends Visible<Bond> implements BondEventListener, Ato
}
@Override
public void onBondWidthChanged(AtomDesign atomDesign, double bondWidth) {
if (bondWidth <= 0.0) {
public void onBondWidthChanged(AtomDesign atomDesign, double bond) {
if (bond <= 0.0) {
return;
} else if (atomDesign == this.atomDesign1) {
if (CYLINDER_SCALE_NORM * Math.abs(bondWidth - this.currentBond1) < RMIN) {
if (CYLINDER_SCALE_NORM * Math.abs(bond - this.currentBond1) < RMIN) {
return;
}
} else if (atomDesign == this.atomDesign2) {
if (CYLINDER_SCALE_NORM * Math.abs(bondWidth - this.currentBond2) < RMIN) {
if (CYLINDER_SCALE_NORM * Math.abs(bond - this.currentBond2) < RMIN) {
return;
}
} else {

View File

@ -30,6 +30,8 @@ public class VisibleCell extends Visible<Cell> implements CellEventListener {
private static final double CYLINDER_SCALE_BOLD = 0.0080;
private static final int CYLINDER_DIV = 6;
private static final double WMIN = 1.0e-3;
private boolean boldMode;
private boolean disableToSelect;
@ -65,6 +67,8 @@ public class VisibleCell extends Visible<Cell> implements CellEventListener {
this.currentWidth = -1.0;
this.currentColor = null;
this.setupDesign();
this.updateVisibleCylinders();
this.updateRadiusOfCylinders();
this.updateXYZOfCylinders();
@ -253,4 +257,47 @@ public class VisibleCell extends Visible<Cell> implements CellEventListener {
children.remove(index);
}
}
private void setupDesign() {
if (this.design == null) {
return;
}
this.design.addOnShowingCellChanged(showing -> {
if (showing == this.currentShowing) {
return;
}
if (!this.currentShowing) {
this.updateRadiusOfCylinders();
this.updateColorOfCylinders();
}
this.updateVisibleCylinders();
});
this.design.addOnCellWidthChanged(width -> {
if (width <= 0.0) {
return;
} else if (Math.abs(width - this.currentWidth) < WMIN) {
return;
}
if (this.currentShowing) {
this.updateRadiusOfCylinders();
}
});
this.design.addOnCellColorChanged(color -> {
if (color == null) {
return;
} else if (color.equals(this.currentColor)) {
return;
}
if (this.currentShowing) {
this.updateColorOfCylinders();
}
});
}
}