use of org.jwildfire.create.tina.dance.motion.Motion in project JWildfire by thargor6.
the class DancingFractalsController method motionTableClicked.
public void motionTableClicked() {
if (!refreshing) {
if (motionPropertyPnl != null) {
motionPropertyRootPnl.remove(motionPropertyPnl);
motionPropertyPnl = null;
}
if (project.getMotions().size() > 0 && motionTable.getSelectedRow() >= 0 && motionTable.getSelectedRow() < project.getMotions().size()) {
Motion motion = project.getMotions().get(motionTable.getSelectedRow());
@SuppressWarnings("rawtypes") Map<Class, PropertyEditor> editors = new HashMap<Class, PropertyEditor>();
editors.put(Motion.class, new MotionTypeEditor(project.getMotions()));
motionPropertyPnl = new PropertyPanel(motion, editors);
motionPropertyPnl.setDescriptionVisible(false);
PropertyChangeListener listener = new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
refreshing = true;
try {
int oldSel = motionTable.getSelectedRow();
refreshMotionTable();
motionTable.getSelectionModel().setSelectionInterval(oldSel, oldSel);
enableControls();
} finally {
refreshing = false;
}
}
};
motionPropertyPnl.addPropertySheetChangeListener(listener);
motionPropertyRootPnl.add(motionPropertyPnl, BorderLayout.CENTER);
enableControls();
}
}
refreshMotionLinksTable();
motionPropertyRootPnl.invalidate();
motionPropertyRootPnl.validate();
}
use of org.jwildfire.create.tina.dance.motion.Motion in project JWildfire by thargor6.
the class DancingFractalsController method refreshMotionLinksTable.
private void refreshMotionLinksTable() {
final int COL_FLAME = 0;
final int COL_PROPERTY = 1;
final Motion currMotion = getSelectedMotion();
motionLinksTable.setModel(new DefaultTableModel() {
private static final long serialVersionUID = 1L;
@Override
public int getRowCount() {
return currMotion != null ? currMotion.getMotionLinks().size() : 0;
}
@Override
public int getColumnCount() {
return 2;
}
@Override
public String getColumnName(int columnIndex) {
switch(columnIndex) {
case COL_FLAME:
return "Flame";
case COL_PROPERTY:
return "Property";
}
return null;
}
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
MotionLink motionLink = rowIndex < currMotion.getMotionLinks().size() ? currMotion.getMotionLinks().get(rowIndex) : null;
if (motionLink != null) {
switch(columnIndex) {
case COL_FLAME:
return flamePropertiesTreeService.getFlameCaption(motionLink.getProperyPath().getFlame());
case COL_PROPERTY:
return motionLink.getProperyPath().getPath();
}
}
return null;
}
@Override
public boolean isCellEditable(int row, int column) {
return false;
}
});
motionLinksTable.getTableHeader().setFont(motionLinksTable.getFont());
motionLinksTable.getColumnModel().getColumn(COL_FLAME).setWidth(80);
motionLinksTable.getColumnModel().getColumn(COL_PROPERTY).setPreferredWidth(120);
}
use of org.jwildfire.create.tina.dance.motion.Motion in project JWildfire by thargor6.
the class DancingFractalsController method addMotionBtn_clicked.
public void addMotionBtn_clicked() {
try {
MotionType motionType = (MotionType) addMotionCmb.getSelectedItem();
if (motionType != null) {
Motion newMotion = motionType.getMotionClass().newInstance();
project.getMotions().add(newMotion);
boolean oldRefreshing = refreshing;
refreshing = true;
try {
refreshMotionTable();
} finally {
refreshing = oldRefreshing;
}
int selectRow = project.getMotions().size() - 1;
motionTable.getSelectionModel().setSelectionInterval(selectRow, selectRow);
}
} catch (Throwable ex) {
errorHandler.handleError(ex);
}
}
use of org.jwildfire.create.tina.dance.motion.Motion in project JWildfire by thargor6.
the class DancingFractalsController method renameMotionBtn_clicked.
public void renameMotionBtn_clicked() {
int row = motionTable.getSelectedRow();
if (row >= 0 && row < project.getMotions().size()) {
Motion motion = project.getMotions().get(row);
String s = StandardDialogs.promptForText(rootPanel, "Please enter the new title:", motion.getDisplayLabel());
if (s != null) {
motion.setCaption(s);
refreshMotionTable();
if (row >= project.getMotions().size()) {
row--;
}
if (row >= 0) {
motionTable.getSelectionModel().setSelectionInterval(row, row);
}
motionTableClicked();
enableControls();
}
}
}
use of org.jwildfire.create.tina.dance.motion.Motion in project JWildfire by thargor6.
the class DancingFlameProject method getMotions.
public List<Motion> getMotions(Flame pFlame) {
List<Motion> res = new ArrayList<Motion>();
for (Motion motion : motions) {
for (MotionLink link : motion.getMotionLinks()) {
if (link.getProperyPath().getFlame().isEqual(pFlame)) {
Motion currMotion = motion;
int iter = 0;
while (currMotion != null) {
res.add(currMotion);
Motion refMotion = currMotion;
currMotion = null;
for (Motion nextMotion : getMotions()) {
if (nextMotion.getParent() == refMotion) {
currMotion = nextMotion;
break;
}
}
iter++;
if (iter > 100) {
throw new RuntimeException("Probably endless loop detected");
}
}
break;
}
}
}
return res;
}
Aggregations