mirror of https://github.com/BURAI-team/burai.git
update VisibleAtom and VisibleBond
This commit is contained in:
parent
97022edef4
commit
8ff806e660
|
@ -39,6 +39,10 @@ public class VisibleAtom extends Visible<Atom> implements AtomEventListener, Ato
|
|||
|
||||
private boolean disableToSelect;
|
||||
|
||||
private double currentRadius;
|
||||
private Color currentColor;
|
||||
private AtomsStyle currentStyle;
|
||||
|
||||
private AtomDesign atomDesign;
|
||||
private AtomDesignAdaptor atomDesignAdaptor;
|
||||
|
||||
|
@ -60,6 +64,10 @@ public class VisibleAtom extends Visible<Atom> implements AtomEventListener, Ato
|
|||
this.atomSphere = new AtomicSphere(this, !this.boldMode);
|
||||
this.disableToSelect = disableToSelect;
|
||||
|
||||
this.currentRadius = -1.0;
|
||||
this.currentColor = null;
|
||||
this.currentStyle = null;
|
||||
|
||||
this.atomDesign = null;
|
||||
this.atomDesignAdaptor = null;
|
||||
|
||||
|
@ -99,6 +107,8 @@ public class VisibleAtom extends Visible<Atom> implements AtomEventListener, Ato
|
|||
radius = this.model.getRadius();
|
||||
}
|
||||
|
||||
this.currentRadius = radius;
|
||||
|
||||
radius *= scale;
|
||||
|
||||
if (this.isSelected()) {
|
||||
|
@ -127,6 +137,8 @@ public class VisibleAtom extends Visible<Atom> implements AtomEventListener, Ato
|
|||
diffuseColor = ElementUtil.getColor(this.model.getName());
|
||||
}
|
||||
|
||||
this.currentColor = diffuseColor;
|
||||
|
||||
material.setDiffuseColor(diffuseColor);
|
||||
material.setSpecularColor(Color.SILVER);
|
||||
this.atomSphere.setMaterial(material);
|
||||
|
@ -228,22 +240,37 @@ public class VisibleAtom extends Visible<Atom> implements AtomEventListener, Ato
|
|||
|
||||
@Override
|
||||
public void onAtomicRadiusChanged(AtomDesign atomDesign, double radius) {
|
||||
if (atomDesign == this.atomDesign && radius > 0.0) {
|
||||
this.updateRadiusOfSphere();
|
||||
if (atomDesign != this.atomDesign || radius <= 0.0) {
|
||||
return;
|
||||
}
|
||||
if (Math.abs(radius - this.currentRadius) < RMIN) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.updateRadiusOfSphere();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAtomicColorChanged(AtomDesign atomDesign, Color color) {
|
||||
if (atomDesign == this.atomDesign && color != null) {
|
||||
this.updateColorOfSphere();
|
||||
if (atomDesign != this.atomDesign || color == null) {
|
||||
return;
|
||||
}
|
||||
if (color.equals(this.currentColor)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.updateColorOfSphere();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAtomsStyleChanged(AtomDesign atomDesign, AtomsStyle atomsStyle) {
|
||||
if (atomDesign == this.atomDesign && atomsStyle != null) {
|
||||
// TODO
|
||||
if (atomDesign != this.atomDesign || atomsStyle == null) {
|
||||
return;
|
||||
}
|
||||
if (atomsStyle == this.currentStyle) {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,6 +39,13 @@ public class VisibleBond extends Visible<Bond> implements BondEventListener, Ato
|
|||
private Cylinder bondCylinder1;
|
||||
private Cylinder bondCylinder2;
|
||||
|
||||
private double currentRadius1;
|
||||
private double currentRadius2;
|
||||
private Color currentColor1;
|
||||
private Color currentColor2;
|
||||
private AtomsStyle currentStyle1;
|
||||
private AtomsStyle currentStyle2;
|
||||
|
||||
private AtomDesign atomDesign1;
|
||||
private AtomDesign atomDesign2;
|
||||
private AtomDesignAdaptor atomDesignAdaptor1;
|
||||
|
@ -59,6 +66,13 @@ public class VisibleBond extends Visible<Bond> implements BondEventListener, Ato
|
|||
this.bondCylinder1 = new Cylinder(radius, 1.0, CYLINDER_DIV);
|
||||
this.bondCylinder2 = new Cylinder(radius, 1.0, CYLINDER_DIV);
|
||||
|
||||
this.currentRadius1 = -1.0;
|
||||
this.currentRadius2 = -1.0;
|
||||
this.currentColor1 = null;
|
||||
this.currentColor2 = null;
|
||||
this.currentStyle1 = null;
|
||||
this.currentStyle2 = null;
|
||||
|
||||
this.atomDesign1 = null;
|
||||
this.atomDesign2 = null;
|
||||
this.atomDesignAdaptor1 = null;
|
||||
|
@ -121,6 +135,8 @@ public class VisibleBond extends Visible<Bond> implements BondEventListener, Ato
|
|||
if (rad1 <= 0.0) {
|
||||
rad1 = atom1.getRadius();
|
||||
}
|
||||
|
||||
this.currentRadius1 = rad1;
|
||||
rad1 = Math.sqrt(Math.max(rad1, 0.0));
|
||||
|
||||
Atom atom2 = this.model.getAtom2();
|
||||
|
@ -136,6 +152,8 @@ public class VisibleBond extends Visible<Bond> implements BondEventListener, Ato
|
|||
if (rad2 <= 0.0) {
|
||||
rad2 = atom2.getRadius();
|
||||
}
|
||||
|
||||
this.currentRadius2 = rad2;
|
||||
rad2 = Math.sqrt(Math.max(rad2, 0.0));
|
||||
|
||||
double dx = x2 - x1;
|
||||
|
@ -182,6 +200,8 @@ public class VisibleBond extends Visible<Bond> implements BondEventListener, Ato
|
|||
color1 = ElementUtil.getColor(atom1.getName());
|
||||
}
|
||||
|
||||
this.currentColor1 = color1;
|
||||
|
||||
PhongMaterial material1 = new PhongMaterial();
|
||||
material1.setDiffuseColor(color1);
|
||||
material1.setSpecularColor(Color.SILVER);
|
||||
|
@ -197,6 +217,8 @@ public class VisibleBond extends Visible<Bond> implements BondEventListener, Ato
|
|||
color2 = ElementUtil.getColor(atom2.getName());
|
||||
}
|
||||
|
||||
this.currentColor2 = color2;
|
||||
|
||||
PhongMaterial material2 = new PhongMaterial();
|
||||
material2.setDiffuseColor(color2);
|
||||
material2.setSpecularColor(Color.SILVER);
|
||||
|
@ -247,24 +269,58 @@ public class VisibleBond extends Visible<Bond> implements BondEventListener, Ato
|
|||
|
||||
@Override
|
||||
public void onAtomicRadiusChanged(AtomDesign atomDesign, double radius) {
|
||||
if (atomDesign == this.atomDesign1 || atomDesign == this.atomDesign2) {
|
||||
if (radius > 0.0) {
|
||||
this.updateXYZOfCylinder();
|
||||
if (radius <= 0.0) {
|
||||
return;
|
||||
} else if (atomDesign == this.atomDesign1) {
|
||||
if (Math.abs(radius - this.currentRadius1) < RMIN) {
|
||||
return;
|
||||
}
|
||||
} else if (atomDesign == this.atomDesign2) {
|
||||
if (Math.abs(radius - this.currentRadius2) < RMIN) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
this.updateXYZOfCylinder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAtomicColorChanged(AtomDesign atomDesign, Color color) {
|
||||
if (atomDesign == this.atomDesign1 || atomDesign == this.atomDesign2) {
|
||||
if (color != null) {
|
||||
this.updateColorOfCylinder();
|
||||
if (color == null) {
|
||||
return;
|
||||
} else if (atomDesign == this.atomDesign1) {
|
||||
if (color.equals(this.currentColor1)) {
|
||||
return;
|
||||
}
|
||||
} else if (atomDesign == this.atomDesign2) {
|
||||
if (color.equals(this.currentColor2)) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
this.updateColorOfCylinder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAtomsStyleChanged(AtomDesign atomDesign, AtomsStyle atomsStyle) {
|
||||
// TODO 自動生成されたメソッド・スタブ
|
||||
if (atomsStyle == null) {
|
||||
return;
|
||||
} else if (atomDesign == this.atomDesign1) {
|
||||
if (atomsStyle == this.currentStyle1) {
|
||||
return;
|
||||
}
|
||||
} else if (atomDesign == this.atomDesign2) {
|
||||
if (atomsStyle == this.currentStyle2) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue