-
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6745447
commit febc60a
Showing
7 changed files
with
126 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
src/main/java/com/marginallyclever/ro3/apps/ode4j/ODEPhysicsSettingsPanel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package com.marginallyclever.ro3.apps.ode4j; | ||
|
||
import com.marginallyclever.convenience.swing.NumberFormatHelper; | ||
import com.marginallyclever.ro3.PanelHelper; | ||
import com.marginallyclever.ro3.Registry; | ||
import com.marginallyclever.ro3.physics.ODEPhysics; | ||
import com.marginallyclever.ro3.view.View; | ||
import com.marginallyclever.ro3.view.ViewProvider; | ||
|
||
import javax.swing.*; | ||
import javax.swing.text.NumberFormatter; | ||
import java.awt.*; | ||
|
||
/** | ||
* {@link ODEPhysicsSettingsPanel} is a {@link View} for {@link ODEPhysics}. | ||
*/ | ||
@View(of= ODE4JPanel.class) | ||
public class ODEPhysicsSettingsPanel extends JPanel implements ViewProvider<ODE4JPanel> { | ||
private ODE4JPanel subject; | ||
private final NumberFormatter formatter = NumberFormatHelper.getNumberFormatter(); | ||
private final JFormattedTextField cfm = new JFormattedTextField(formatter); | ||
private final JFormattedTextField erp = new JFormattedTextField(formatter); | ||
private final JFormattedTextField gravity = new JFormattedTextField(formatter); | ||
|
||
public ODEPhysicsSettingsPanel() { | ||
super(new GridBagLayout()); | ||
setName("Physics"); | ||
|
||
GridBagConstraints gbc = new GridBagConstraints(); | ||
gbc.weightx = 1.0; | ||
gbc.weighty = 1.0; | ||
gbc.gridx=0; | ||
gbc.gridy=0; | ||
gbc.fill = GridBagConstraints.BOTH; | ||
|
||
var physics = Registry.getPhysics(); | ||
// cfm | ||
cfm.setValue(physics.getCFM()); | ||
PanelHelper.addLabelAndComponent(this, "CFM",cfm,gbc); | ||
cfm.addPropertyChangeListener("value", evt -> setCFM((Double) evt.getNewValue())); | ||
|
||
// erp | ||
gbc.gridy++; | ||
erp.setValue(physics.getERP()); | ||
PanelHelper.addLabelAndComponent(this, "ERP",erp,gbc); | ||
erp.addPropertyChangeListener("value", evt -> setERP((Double) evt.getNewValue())); | ||
|
||
// gravity | ||
gbc.gridy++; | ||
gravity.setValue(physics.getGravity()); | ||
PanelHelper.addLabelAndComponent(this, "Gravity",gravity,gbc); | ||
gravity.addPropertyChangeListener("value", evt ->setGravity((Double) evt.getNewValue())); | ||
} | ||
|
||
public void setCFM(double cfm) { | ||
var physics = Registry.getPhysics(); | ||
physics.setCFM(cfm); | ||
} | ||
|
||
public void setERP(double erp) { | ||
var physics = Registry.getPhysics(); | ||
physics.setERP(erp); | ||
} | ||
|
||
public void setGravity(double gravity) { | ||
var physics = Registry.getPhysics(); | ||
physics.setGravity(gravity); | ||
} | ||
|
||
@Override | ||
public void setViewSubject(ODE4JPanel subject) { | ||
this.subject = subject; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 0 additions & 11 deletions
11
src/main/java/com/marginallyclever/ro3/physics/ODEPhysicsPanel.java
This file was deleted.
Oops, something went wrong.