From 50b07b185e1d01ebe59e3640dbaa51095cd775b1 Mon Sep 17 00:00:00 2001 From: nisihara1 Date: Fri, 11 Aug 2017 14:37:20 +0900 Subject: [PATCH] update VisibleCell --- src/burai/atoms/visible/VisibleAtom.java | 1 + src/burai/atoms/visible/VisibleBond.java | 9 +++-- src/burai/atoms/visible/VisibleCell.java | 47 ++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 4 deletions(-) diff --git a/src/burai/atoms/visible/VisibleAtom.java b/src/burai/atoms/visible/VisibleAtom.java index 11b8694..0ef51eb 100644 --- a/src/burai/atoms/visible/VisibleAtom.java +++ b/src/burai/atoms/visible/VisibleAtom.java @@ -87,6 +87,7 @@ public class VisibleAtom extends Visible implements AtomEventListener, Ato this.updateXYZOfSphere(); this.updateColorOfSphere(); this.updateDrawMode(); + this.getChildren().add(this.atomSphere); } diff --git a/src/burai/atoms/visible/VisibleBond.java b/src/burai/atoms/visible/VisibleBond.java index 4d1e4e4..b892ef2 100644 --- a/src/burai/atoms/visible/VisibleBond.java +++ b/src/burai/atoms/visible/VisibleBond.java @@ -86,6 +86,7 @@ public class VisibleBond extends Visible 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 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 { diff --git a/src/burai/atoms/visible/VisibleCell.java b/src/burai/atoms/visible/VisibleCell.java index 069a51c..0c1ffe4 100644 --- a/src/burai/atoms/visible/VisibleCell.java +++ b/src/burai/atoms/visible/VisibleCell.java @@ -30,6 +30,8 @@ public class VisibleCell extends Visible 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 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 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(); + } + }); + } }